q3map2/light: introduce -nobouncestore

when storing computed lightmap on each bounce, user can interrupt compilation and
get working files, but it spends allocation time (which is slow and single-threaded

with this option, user can decide to only allocate lightmaps on the very final
bounce, it means it can't be interrupted, but it can save a lot of time
This commit is contained in:
Thomas Debesse 2019-09-22 02:16:08 +02:00 committed by Garux
parent 374f66bb42
commit 2c947b7e95
5 changed files with 423 additions and 399 deletions

View File

@ -257,6 +257,7 @@ td.formatted_questions ol { margin-top: 0px; margin-bottom: 0px; }
<li><strong><code>-lomem</code>:</strong> Low memory but slower lighting mode</li>
<li><strong><code>-lowquality</code>:</strong> Low quality floodlight (appears to currently break floodlight)</li>
<li><strong><code>-minsamplesize</code> N:</strong> Sets minimum lightmap resolution in luxels/qu</li>
<li><strong><code>-nobouncestore</code>:</strong> Do not store BSP, lightmap and shader files between bounces</li>
<li><strong><code>-nocollapse</code>:</strong> Do not collapse identical lightmaps</li>
<li><strong><code>-nodeluxe</code>, <code>-nodeluxemap</code>:</strong> Disable deluxemapping</li>
<li><strong><code>-nofastpoint</code>:</strong> Disable fast point light calculation</li>

View File

@ -224,6 +224,7 @@ static void HelpLight()
{"-lomem", "Low memory but slower lighting mode"},
{"-lowquality", "Low quality floodlight (appears to currently break floodlight)"},
{"-minsamplesize <N>", "Sets minimum lightmap resolution in luxels/qu"},
{"-nobouncestore", "Do not store BSP, lightmap and shader files between bounces"},
{"-nocollapse", "Do not collapse identical lightmaps"},
{"-nodeluxe, -nodeluxemap", "Disable deluxemapping"},
{"-nofastpoint", "Disable fast point light calculation"},

View File

@ -1785,7 +1785,7 @@ static void SetupGrid(){
does what it says...
*/
static void LightWorld( bool fastAllocate ){
static void LightWorld( bool fastAllocate, bool bounceStore ){
Vector3 color;
float f;
int b, bt;
@ -1917,10 +1917,12 @@ static void LightWorld( bool fastAllocate ){
while ( bounce > 0 )
{
/* store off the bsp between bounces */
StoreSurfaceLightmaps( fastAllocate );
StoreSurfaceLightmaps( fastAllocate, bounceStore );
if( bounceStore ){
UnparseEntities();
Sys_Printf( "Writing %s\n", source );
WriteBSPFile( source );
}
/* note it */
Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
@ -1939,8 +1941,11 @@ static void LightWorld( bool fastAllocate ){
SetupEnvelopes( false, fastbounce );
if ( lights.empty() ) {
Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
if( bounceStore ){ // already stored, just quit
return;
}
break; // break to StoreSurfaceLightmaps
}
/* add to lightgrid */
if ( bouncegrid ) {
@ -1982,8 +1987,9 @@ static void LightWorld( bool fastAllocate ){
bounce--;
b++;
}
/* ydnar: store off lightmaps */
StoreSurfaceLightmaps( fastAllocate );
StoreSurfaceLightmaps( fastAllocate, true );
}
@ -1998,6 +2004,7 @@ int LightMain( Args& args ){
int lightmapMergeSize = 0;
bool lightSamplesInsist = false;
bool fastAllocate = true;
bool bounceStore = true;
/* note it */
@ -2445,6 +2452,11 @@ int LightMain( Args& args ){
Sys_Printf( "Storing bounced light (radiosity) only\n" );
}
while ( args.takeArg( "-nobouncestore" ) ) {
bounceStore = false;
Sys_Printf( "Not storing BSP, lightmap and shader files between bounces\n" );
}
while ( args.takeArg( "-nocollapse" ) ) {
noCollapse = true;
Sys_Printf( "Identical lightmap collapsing disabled\n" );
@ -2814,7 +2826,7 @@ int LightMain( Args& args ){
SetupTraceNodes();
/* light the world */
LightWorld( fastAllocate );
LightWorld( fastAllocate, bounceStore );
/* write out the bsp */
UnparseEntities();

View File

@ -2336,7 +2336,7 @@ static void FillOutLightmap( outLightmap_t *olm ){
stores the surface lightmaps into the bsp as byte rgb triplets
*/
void StoreSurfaceLightmaps( bool fastAllocate ){
void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){
int i, j, k, x, y, lx, ly, sx, sy, mappedSamples;
int style, lightmapNum, lightmapNum2;
float samples, occludedSamples;
@ -2816,7 +2816,7 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
collapse non-unique lightmaps
----------------------------------------------------------------- */
if ( !noCollapse && !deluxemap ) {
if ( storeForReal && !noCollapse && !deluxemap ) {
/* note it */
Sys_Printf( "collapsing..." );
@ -2890,6 +2890,7 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
sort raw lightmaps by shader
----------------------------------------------------------------- */
if ( storeForReal ) {
/* note it */
Sys_Printf( "sorting..." );
@ -2906,11 +2907,13 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
std::sort( sortLightmaps, sortLightmaps + numRawLightmaps, CompareRawLightmap() );
Sys_Printf( "%d.", int( timer.elapsed_sec() ) );
}
/* -----------------------------------------------------------------
allocate output lightmaps
----------------------------------------------------------------- */
if ( storeForReal ) {
/* note it */
Sys_Printf( "allocating..." );
@ -2963,11 +2966,13 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
}
Sys_Printf( "%d.", int( timer.elapsed_sec() ) );
}
/* -----------------------------------------------------------------
store output lightmaps
----------------------------------------------------------------- */
if ( storeForReal ) {
/* note it */
Sys_Printf( "storing..." );
@ -3060,11 +3065,13 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
}
Sys_Printf( "%d.", int( timer.elapsed_sec() ) );
}
/* -----------------------------------------------------------------
project the lightmaps onto the bsp surfaces
----------------------------------------------------------------- */
if ( storeForReal ) {
/* note it */
Sys_Printf( "projecting..." );
@ -3344,10 +3351,12 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
}
Sys_Printf( "%d.", int( timer.elapsed_sec() ) );
}
/* finish */
Sys_Printf( "done.\n" );
if ( storeForReal ) {
/* calc num stored */
numStored = bspLightBytes.size() / 3;
efficiency = ( numStored <= 0 )
@ -3367,4 +3376,5 @@ void StoreSurfaceLightmaps( bool fastAllocate ){
/* write map shader file */
WriteMapShaderFile();
}
}

View File

@ -1649,7 +1649,7 @@ int ImportLightmapsMain( Args& args );
void SetupSurfaceLightmaps();
void StitchSurfaceLightmaps();
void StoreSurfaceLightmaps( bool fastAllocate );
void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal );
/* exportents.c */