[iortcw] 467/497: All: Rend2: Add option in code for alternate overbright method
This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw. commit d210625caf3036a894fb7ea4ac9da925fe659e2b Author: MAN-AT-ARMS Date: Thu Dec 10 11:20:19 2015 -0500 All: Rend2: Add option in code for alternate overbright method --- MP/code/rend2/tr_bsp.c | 11 ++- MP/code/rend2/tr_image.c | 4 MP/code/rend2/tr_local.h | 2 +- MP/code/rend2/tr_scene.c | 4 MP/code/rend2/tr_shade.c | 23 --- SP/code/rend2/tr_bsp.c | 10 ++ SP/code/rend2/tr_image.c | 4 SP/code/rend2/tr_local.h | 2 +- SP/code/rend2/tr_scene.c | 4 SP/code/rend2/tr_shade.c | 23 --- 10 files changed, 70 insertions(+), 17 deletions(-) diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c index 399f2fc..cd4a1b2 100644 --- a/MP/code/rend2/tr_bsp.c +++ b/MP/code/rend2/tr_bsp.c @@ -107,7 +107,11 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { int shift, r, g, b; // shift the color data based on overbright range +#if defined(USE_OVERBRIGHT) shift = r_mapOverBrightBits->integer - tr.overbrightBits; +#else + shift = 0; +#endif // shift the data based on overbright range r = in[0] << shift; @@ -141,7 +145,9 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) { float r, g, b; +#if defined(USE_OVERBRIGHT) scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); +#endif r = in[0] * scale; g = in[1] * scale; @@ -3105,8 +3111,11 @@ void R_LoadLightGrid( lump_t *l ) { if (hdrLightGrid) { +#if defined(USE_OVERBRIGHT) float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits); - +#else + float lightScale = 1.0f; +#endif //ri.Printf(PRINT_ALL, "found!\n"); if (size != sizeof(float) * 6 * numGridPoints) diff --git a/MP/code/rend2/tr_image.c b/MP/code/rend2/tr_image.c index b6644ce..1dacfff 100644 --- a/MP/code/rend2/tr_image.c +++ b/MP/code/rend2/tr_image.c @@ -3029,7 +3029,11 @@ void R_SetColorMappings( void ) { int inf; // setup the overbright lighting +#if defined(USE_OVERBRIGHT) tr.overbrightBits = r_overBrightBits->integer; +#else + tr.overbrightBits = 0; +#endif // allow 2 overbright bits if ( tr.overbrightBits > 2 ) { diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h index a3958db..8d46e50 100644 --- a/MP/code/rend2/tr_local.h +++ b/MP/code/rend2/tr_local.h @@ -65,7 +65,7 @@ typedef unsigned int glIndex_t; #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) #define USE_VERT_TANGENT_SPACE - +#define USE_OVERBRIGHT // a trRefEntity_t has all the information passed in by // the client game, as well as some locally derived info diff --git a/MP/code/rend2/tr_scene.c b/MP/code/rend2/tr_scene.c index 68cd57c..c2b96f1 100644 --- a/MP/code/rend2/tr_scene.c +++ b/MP/code/rend2/tr_scene.c @@ -465,7 +465,11 @@ void RE_BeginScene(const refdef_t *fd) } else { +#if defined(USE_OVERBRIGHT) float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); +#else + float scale = (1 << r_mapOverBrightBits->integer) / 255.0f; +#endif if (r_forceSun->integer) { VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c index b5d6709..abd214e 100644 --- a/MP/code/rend2/tr_shade.c +++ b/MP/code/rend2/tr_shade.c @@ -479,9 +479,22 @@ static void ProjectDlightTexture( void ) { static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend ) { + qboolean isBlend = ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) + || ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) + || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) + || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); + + qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL); + +#if defined(USE_OVERBRIGHT) + float exactLight = 1.0f; +#else + float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << r_mapOverBrightBits->integer); +#endif + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = exactLight; baseColor[3] = 1.0f; vertColor[0] = @@ -508,7 +521,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[0] = vertColor[1] = - vertColor[2] = +
[iortcw] 467/497: All: Rend2: Add option in code for alternate overbright method
This is an automated email from the git hooks/post-receive script. smcv pushed a commit to annotated tag 1.42d in repository iortcw. commit d210625caf3036a894fb7ea4ac9da925fe659e2b Author: MAN-AT-ARMS Date: Thu Dec 10 11:20:19 2015 -0500 All: Rend2: Add option in code for alternate overbright method --- MP/code/rend2/tr_bsp.c | 11 ++- MP/code/rend2/tr_image.c | 4 MP/code/rend2/tr_local.h | 2 +- MP/code/rend2/tr_scene.c | 4 MP/code/rend2/tr_shade.c | 23 --- SP/code/rend2/tr_bsp.c | 10 ++ SP/code/rend2/tr_image.c | 4 SP/code/rend2/tr_local.h | 2 +- SP/code/rend2/tr_scene.c | 4 SP/code/rend2/tr_shade.c | 23 --- 10 files changed, 70 insertions(+), 17 deletions(-) diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c index 399f2fc..cd4a1b2 100644 --- a/MP/code/rend2/tr_bsp.c +++ b/MP/code/rend2/tr_bsp.c @@ -107,7 +107,11 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { int shift, r, g, b; // shift the color data based on overbright range +#if defined(USE_OVERBRIGHT) shift = r_mapOverBrightBits->integer - tr.overbrightBits; +#else + shift = 0; +#endif // shift the data based on overbright range r = in[0] << shift; @@ -141,7 +145,9 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) { float r, g, b; +#if defined(USE_OVERBRIGHT) scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); +#endif r = in[0] * scale; g = in[1] * scale; @@ -3105,8 +3111,11 @@ void R_LoadLightGrid( lump_t *l ) { if (hdrLightGrid) { +#if defined(USE_OVERBRIGHT) float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits); - +#else + float lightScale = 1.0f; +#endif //ri.Printf(PRINT_ALL, "found!\n"); if (size != sizeof(float) * 6 * numGridPoints) diff --git a/MP/code/rend2/tr_image.c b/MP/code/rend2/tr_image.c index b6644ce..1dacfff 100644 --- a/MP/code/rend2/tr_image.c +++ b/MP/code/rend2/tr_image.c @@ -3029,7 +3029,11 @@ void R_SetColorMappings( void ) { int inf; // setup the overbright lighting +#if defined(USE_OVERBRIGHT) tr.overbrightBits = r_overBrightBits->integer; +#else + tr.overbrightBits = 0; +#endif // allow 2 overbright bits if ( tr.overbrightBits > 2 ) { diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h index a3958db..8d46e50 100644 --- a/MP/code/rend2/tr_local.h +++ b/MP/code/rend2/tr_local.h @@ -65,7 +65,7 @@ typedef unsigned int glIndex_t; #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) #define USE_VERT_TANGENT_SPACE - +#define USE_OVERBRIGHT // a trRefEntity_t has all the information passed in by // the client game, as well as some locally derived info diff --git a/MP/code/rend2/tr_scene.c b/MP/code/rend2/tr_scene.c index 68cd57c..c2b96f1 100644 --- a/MP/code/rend2/tr_scene.c +++ b/MP/code/rend2/tr_scene.c @@ -465,7 +465,11 @@ void RE_BeginScene(const refdef_t *fd) } else { +#if defined(USE_OVERBRIGHT) float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); +#else + float scale = (1 << r_mapOverBrightBits->integer) / 255.0f; +#endif if (r_forceSun->integer) { VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c index b5d6709..abd214e 100644 --- a/MP/code/rend2/tr_shade.c +++ b/MP/code/rend2/tr_shade.c @@ -479,9 +479,22 @@ static void ProjectDlightTexture( void ) { static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend ) { + qboolean isBlend = ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) + || ((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) + || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) + || ((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR); + + qboolean isWorldDraw = !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL); + +#if defined(USE_OVERBRIGHT) + float exactLight = 1.0f; +#else + float exactLight = (isBlend || !isWorldDraw) ? 1.0f : (float)(1 << r_mapOverBrightBits->integer); +#endif + baseColor[0] = baseColor[1] = - baseColor[2] = + baseColor[2] = exactLight; baseColor[3] = 1.0f; vertColor[0] = @@ -508,7 +521,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[0] = vertColor[1] = - vertColor[2] = +