From 55df37941c7769d7b918733dfcbdb6038975969f Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 20 May 2016 12:00:57 -0600 Subject: [PATCH] light: add -bouncecolorscale flag --- include/light/light.h | 3 ++- light/entities.c | 4 ++++ light/light.cc | 5 +++++ light/ltface.c | 9 ++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/light/light.h b/include/light/light.h index 48baa3b1..ea46d569 100644 --- a/include/light/light.h +++ b/include/light/light.h @@ -232,7 +232,8 @@ extern qboolean dirtAngleSetOnCmdline; extern qboolean bounce; extern qboolean bouncedebug; extern vec_t bouncescale; - +extern vec_t bouncecolorscale; + /* * Return space for the lightmap and colourmap at the same time so it can * be done in a thread-safe manner. diff --git a/light/entities.c b/light/entities.c index 96284287..3b3cf147 100644 --- a/light/entities.c +++ b/light/entities.c @@ -1062,6 +1062,10 @@ LoadEntities(const bsp2_t *bsp) bouncescale = atof(com_token); logprint("_bouncescale set to %f\n", bouncescale); } + else if (!strcmp(key, "_bouncecolorscale")) { + bouncecolorscale = atof(com_token); + logprint("_bouncecolorscale set to %f\n", bouncecolorscale); + } } /* diff --git a/light/light.cc b/light/light.cc index 543c60a2..041d49b5 100644 --- a/light/light.cc +++ b/light/light.cc @@ -74,6 +74,7 @@ qboolean dirtAngleSetOnCmdline = false; qboolean bounce = false; qboolean bouncedebug = false; vec_t bouncescale = 1.0f; +vec_t bouncecolorscale = 0.0f; qboolean testFenceTextures = false; qboolean surflight_dump = false; @@ -1318,6 +1319,10 @@ main(int argc, const char **argv) bounce = true; bouncescale = atof( argv[ ++i ] ); logprint( "Bounce scale factor set to %f on command line\n", bouncescale ); + } 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 ); } else if ( !strcmp( argv[ i ], "-fence" ) ) { testFenceTextures = true; logprint( "Fence texture tracing enabled on command line\n" ); diff --git a/light/ltface.c b/light/ltface.c index 7010a789..9caae2bb 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -2164,9 +2164,16 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, // make bounce light if (bounce) { + 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); + vec3_t emitcolor; for (int k=0; k<3; k++) { - emitcolor[k] = (lightsurf->radiosity[k] / 255.0f) * (lightsurf->texturecolor[k] / 255.0f); + emitcolor[k] = (lightsurf->radiosity[k] / 255.0f) * (blendedcolor[k] / 255.0f); } winding_t *w = WindingFromFace(bsp, face); AddBounceLight(lightsurf->midpoint, emitcolor, lightsurf->plane.normal, WindingArea(w), bsp);