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 */
extern qboolean bounce;
extern vec_t bouncescale;
extern vec_t bouncecolorscale;
extern lockable_vec_t bounce;
extern lockable_vec_t bouncescale;
extern lockable_vec_t bouncecolorscale;
/*
* 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);
}
else if (!strcmp(key, "_bounce")) {
bounce = atoi(com_token);
logprint("_bounce set to %d\n", bounce);
if (!bounce.locked) {
bounce.value = atoi(com_token);
logprint("_bounce set to %d\n", (int)bounce.value);
}
}
else if (!strcmp(key, "_bouncescale")) {
bouncescale = atof(com_token);
logprint("_bouncescale set to %f\n", bouncescale);
if (!bouncescale.locked) {
bouncescale.value = atof(com_token);
logprint("_bouncescale set to %f\n", bouncescale.value);
}
}
else if (!strcmp(key, "_bouncecolorscale")) {
bouncecolorscale = atof(com_token);
logprint("_bouncecolorscale set to %f\n", bouncecolorscale);
if (!bouncecolorscale.locked) {
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};
/* bounce */
qboolean bounce = false;
vec_t bouncescale = 1.0f;
vec_t bouncecolorscale = 0.0f;
lockable_vec_t bounce = {0, false};
lockable_vec_t bouncescale = {1.0f, false};
lockable_vec_t bouncecolorscale = {0.0f, 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.
* Otherwise free memory now, so only (# threads) lightmaps are in memory at a time.
*/
if (!bounce) {
if (!bounce.value) {
LightFaceShutdown(ctx);
}
}
@ -729,7 +729,7 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
logprint("==LightThread==\n");
RunThreadsOn(0, bsp->numfaces, LightThread, bsp);
if (bounce) {
if (bounce.value) {
logprint("==LightThreadBounce==\n");
RunThreadsOn(0, bsp->numfaces, LightThreadBounce, bsp);
}
@ -1343,21 +1343,36 @@ main(int argc, const char **argv)
logprint( "Phong shading disabled\n" );
}
} else if ( !strcmp( argv[ i ], "-bounce" ) ) {
bounce = true;
logprint( "Bounce enabled on command line\n" );
int bounce_param = 1;
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" ) ) {
CheckNoDebugModeSet();
bounce = true;
bounce.value = true;
bounce.locked = true;
debugmode = debugmode_bounce;
logprint( "Bounce debugging mode enabled on command line\n" );
} else if ( !strcmp( argv[ i ], "-bouncescale" ) ) {
bounce = true;
bouncescale = atof( argv[ ++i ] );
logprint( "Bounce scale factor set to %f on command line\n", bouncescale );
bounce.value = true;
bounce.locked = true;
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" ) ) {
bounce = true;
bouncecolorscale = atof( argv[ ++i ] );
logprint( "Bounce color scale factor set to %f on command line\n", bouncecolorscale );
bounce.value = true;
bounce.locked = true;
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" ) ) {
surflight_subdivide = atof( argv[ ++i ] );
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 scale = (1.0/dist2) * bouncescale;
const vec_t scale = (1.0/dist2) * bouncescale.value;
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;
if (!bounce)
if (!bounce.value)
return;
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);
if (bounce) {
if (bounce.value) {
// make bounce light, only if this face is shadow casting
if (modelinfo->shadow) {
vec3_t gray = {127, 127, 127};
// lerp between gray and the texture color according to `bouncecolorscale`
vec3_t blendedcolor = {0, 0, 0};
VectorMA(blendedcolor, bouncecolorscale, lightsurf->texturecolor, blendedcolor);
VectorMA(blendedcolor, 1-bouncecolorscale, gray, blendedcolor);
VectorMA(blendedcolor, bouncecolorscale.value, lightsurf->texturecolor, blendedcolor);
VectorMA(blendedcolor, 1-bouncecolorscale.value, gray, blendedcolor);
vec3_t emitcolor;
for (int k=0; k<3; k++) {