light: allow disabling bounce on command line

This commit is contained in:
Eric Wasylishen 2016-05-27 18:47:12 -06:00
parent bb19618763
commit 21a4fd5287
4 changed files with 49 additions and 28 deletions

View File

@ -245,9 +245,9 @@ extern lockable_vec_t phongallowed;
/* bounce */ /* bounce */
extern qboolean bounce; extern lockable_vec_t bounce;
extern vec_t bouncescale; extern lockable_vec_t bouncescale;
extern vec_t bouncecolorscale; extern lockable_vec_t bouncecolorscale;
/* /*
* Return space for the lightmap and colourmap at the same time so it can * Return space for the lightmap and colourmap at the same time so it can

View File

@ -1055,16 +1055,22 @@ LoadEntities(const bsp2_t *bsp)
logprint("using lightmap gamma value %f\n", lightmapgamma); logprint("using lightmap gamma value %f\n", lightmapgamma);
} }
else if (!strcmp(key, "_bounce")) { else if (!strcmp(key, "_bounce")) {
bounce = atoi(com_token); if (!bounce.locked) {
logprint("_bounce set to %d\n", bounce); bounce.value = atoi(com_token);
logprint("_bounce set to %d\n", (int)bounce.value);
}
} }
else if (!strcmp(key, "_bouncescale")) { else if (!strcmp(key, "_bouncescale")) {
bouncescale = atof(com_token); if (!bouncescale.locked) {
logprint("_bouncescale set to %f\n", bouncescale); bouncescale.value = atof(com_token);
logprint("_bouncescale set to %f\n", bouncescale.value);
}
} }
else if (!strcmp(key, "_bouncecolorscale")) { else if (!strcmp(key, "_bouncecolorscale")) {
bouncecolorscale = atof(com_token); if (!bouncecolorscale.locked) {
logprint("_bouncecolorscale set to %f\n", bouncecolorscale); bouncecolorscale.value = atof(com_token);
logprint("_bouncecolorscale set to %f\n", bouncecolorscale.value);
}
} }
} }

View File

@ -66,9 +66,9 @@ qboolean minlightDirt = false;
lockable_vec_t phongallowed = {1, false}; lockable_vec_t phongallowed = {1, false};
/* bounce */ /* bounce */
qboolean bounce = false; lockable_vec_t bounce = {0, false};
vec_t bouncescale = 1.0f; lockable_vec_t bouncescale = {1.0f, false};
vec_t bouncecolorscale = 0.0f; lockable_vec_t bouncecolorscale = {0.0f, false};
qboolean surflight_dump = false; qboolean surflight_dump = false;
@ -206,7 +206,7 @@ LightThread(void *arg)
/* If bouncing, keep lightmaps in memory because we run a second lighting pass. /* If bouncing, keep lightmaps in memory because we run a second lighting pass.
* Otherwise free memory now, so only (# threads) lightmaps are in memory at a time. * Otherwise free memory now, so only (# threads) lightmaps are in memory at a time.
*/ */
if (!bounce) { if (!bounce.value) {
LightFaceShutdown(ctx); LightFaceShutdown(ctx);
} }
} }
@ -729,7 +729,7 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
logprint("==LightThread==\n"); logprint("==LightThread==\n");
RunThreadsOn(0, bsp->numfaces, LightThread, bsp); RunThreadsOn(0, bsp->numfaces, LightThread, bsp);
if (bounce) { if (bounce.value) {
logprint("==LightThreadBounce==\n"); logprint("==LightThreadBounce==\n");
RunThreadsOn(0, bsp->numfaces, LightThreadBounce, bsp); RunThreadsOn(0, bsp->numfaces, LightThreadBounce, bsp);
} }
@ -1343,21 +1343,36 @@ main(int argc, const char **argv)
logprint( "Phong shading disabled\n" ); logprint( "Phong shading disabled\n" );
} }
} else if ( !strcmp( argv[ i ], "-bounce" ) ) { } else if ( !strcmp( argv[ i ], "-bounce" ) ) {
bounce = true; int bounce_param = 1;
logprint( "Bounce enabled on command line\n" );
if ((i + 1) < argc && isdigit(argv[i + 1][0])) {
bounce_param = atoi( argv[ ++i ] );
}
bounce.value = bounce_param;
bounce.locked = true;
if (bounce_param)
logprint( "Bounce enabled on command line\n");
else
logprint( "Bounce disabled on command line\n");
} else if ( !strcmp( argv[ i ], "-bouncedebug" ) ) { } else if ( !strcmp( argv[ i ], "-bouncedebug" ) ) {
CheckNoDebugModeSet(); CheckNoDebugModeSet();
bounce = true; bounce.value = true;
bounce.locked = true;
debugmode = debugmode_bounce; debugmode = debugmode_bounce;
logprint( "Bounce debugging mode enabled on command line\n" ); logprint( "Bounce debugging mode enabled on command line\n" );
} else if ( !strcmp( argv[ i ], "-bouncescale" ) ) { } else if ( !strcmp( argv[ i ], "-bouncescale" ) ) {
bounce = true; bounce.value = true;
bouncescale = atof( argv[ ++i ] ); bounce.locked = true;
logprint( "Bounce scale factor set to %f on command line\n", bouncescale ); bouncescale.value = atof( argv[ ++i ] );
bouncescale.locked = true;
logprint( "Bounce scale factor set to %f on command line\n", bouncescale.value );
} else if ( !strcmp( argv[ i ], "-bouncecolorscale" ) ) { } else if ( !strcmp( argv[ i ], "-bouncecolorscale" ) ) {
bounce = true; bounce.value = true;
bouncecolorscale = atof( argv[ ++i ] ); bounce.locked = true;
logprint( "Bounce color scale factor set to %f on command line\n", bouncecolorscale ); bouncecolorscale.value = atof( argv[ ++i ] );
bouncecolorscale.locked = true;
logprint( "Bounce color scale factor set to %f on command line\n", bouncecolorscale.value );
} else if ( !strcmp( argv[ i ], "-surflight_subdivide" ) ) { } else if ( !strcmp( argv[ i ], "-surflight_subdivide" ) ) {
surflight_subdivide = atof( argv[ ++i ] ); surflight_subdivide = atof( argv[ ++i ] );
surflight_subdivide = qmin(qmax(surflight_subdivide, 64.0f), 2048.0f); surflight_subdivide = qmin(qmax(surflight_subdivide, 64.0f), 2048.0f);

View File

@ -1597,7 +1597,7 @@ BounceLight_ColorAtDist(const bouncelight_t *vpl, vec_t dist, vec3_t color)
} }
const vec_t dist2 = (dist * dist); const vec_t dist2 = (dist * dist);
const vec_t scale = (1.0/dist2) * bouncescale; const vec_t scale = (1.0/dist2) * bouncescale.value;
VectorScale(color, 255 * scale, color); VectorScale(color, 255 * scale, color);
} }
@ -1655,7 +1655,7 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t
lightmap_t *lightmap; lightmap_t *lightmap;
if (!bounce) if (!bounce.value)
return; return;
if (!(debugmode == debugmode_bounce if (!(debugmode == debugmode_bounce
@ -2195,15 +2195,15 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
} }
VectorScale(lightsurf->texturecolor, 1.0f/lightsurf->numpoints, lightsurf->texturecolor); VectorScale(lightsurf->texturecolor, 1.0f/lightsurf->numpoints, lightsurf->texturecolor);
if (bounce) { if (bounce.value) {
// make bounce light, only if this face is shadow casting // make bounce light, only if this face is shadow casting
if (modelinfo->shadow) { if (modelinfo->shadow) {
vec3_t gray = {127, 127, 127}; vec3_t gray = {127, 127, 127};
// lerp between gray and the texture color according to `bouncecolorscale` // lerp between gray and the texture color according to `bouncecolorscale`
vec3_t blendedcolor = {0, 0, 0}; vec3_t blendedcolor = {0, 0, 0};
VectorMA(blendedcolor, bouncecolorscale, lightsurf->texturecolor, blendedcolor); VectorMA(blendedcolor, bouncecolorscale.value, lightsurf->texturecolor, blendedcolor);
VectorMA(blendedcolor, 1-bouncecolorscale, gray, blendedcolor); VectorMA(blendedcolor, 1-bouncecolorscale.value, gray, blendedcolor);
vec3_t emitcolor; vec3_t emitcolor;
for (int k=0; k<3; k++) { for (int k=0; k<3; k++) {