diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 3af41a6d68..47d19c524b 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -573,6 +573,7 @@ static std::string GenEngineConstants() { if ( glConfig2.dynamicLight ) { AddDefine( str, "r_dynamicLight", 1 ); + AddDefine( str, "r_dynamicLightRenderer", r_dynamicLightRenderer.Get() ); } if ( r_precomputedLighting->integer ) diff --git a/src/engine/renderer/glsl_source/computeLight_fp.glsl b/src/engine/renderer/glsl_source/computeLight_fp.glsl index 194acd3110..4513748ae0 100644 --- a/src/engine/renderer/glsl_source/computeLight_fp.glsl +++ b/src/engine/renderer/glsl_source/computeLight_fp.glsl @@ -175,7 +175,8 @@ int nextIdx( inout idxs_t idxs ) { const int numLayers = MAX_REF_LIGHTS / 256; -#if defined(r_dynamicLight) +// This code is only used by the tiled dynamic light renderer. +#if defined(r_dynamicLight) && r_dynamicLightRenderer == 1 void computeDynamicLight( int idx, vec3 P, vec3 normal, vec3 viewDir, vec4 diffuse, vec4 material, inout vec4 color ) { vec4 center_radius = GetLight( idx, center_radius ); diff --git a/src/engine/renderer/glsl_source/lightMapping_fp.glsl b/src/engine/renderer/glsl_source/lightMapping_fp.glsl index 63ec85c6c6..1aa67b33c2 100644 --- a/src/engine/renderer/glsl_source/lightMapping_fp.glsl +++ b/src/engine/renderer/glsl_source/lightMapping_fp.glsl @@ -161,8 +161,8 @@ void main() computeLight(lightColor, diffuse, color); #endif - // Blend dynamic lights. - #if defined(r_dynamicLight) + // Blend dynamic lights, this code is only used by the tiled dynamic light renderer. + #if defined(r_dynamicLight) && r_dynamicLightRenderer == 1 computeDynamicLights(var_Position, normal, viewDir, diffuse, material, color); #endif diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index 781550e7e7..c99eb83699 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -510,54 +510,55 @@ void Tess_Begin( void ( *stageIteratorFunc )(), int fogNum, bool bspSurface ) { - shader_t *state; - tess.numIndexes = 0; tess.numVertexes = 0; tess.attribsSet = 0; tess.multiDrawPrimitives = 0; + tess.stageIteratorFunc = stageIteratorFunc; + tess.stageIteratorFunc2 = stageIteratorFunc2; + + tess.surfaceShader = surfaceShader; + tess.lightShader = lightShader; + + tess.skipTangentSpaces = skipTangentSpaces; + tess.lightmapNum = lightmapNum; + tess.fogNum = fogNum; + tess.bspSurface = bspSurface; + // materials are optional - if ( surfaceShader != nullptr ) + if ( tess.surfaceShader ) { - state = ( surfaceShader->remappedShader ) ? surfaceShader->remappedShader : surfaceShader; + if ( tess.surfaceShader->remappedShader ) + { + tess.surfaceShader = surfaceShader->remappedShader; + } - tess.surfaceShader = state; - tess.surfaceStages = state->stages; - tess.surfaceLastStage = state->lastStage; + if ( tess.surfaceShader->isSky ) + { + tess.stageIteratorFunc = &Tess_StageIteratorSky; + } - Tess_MapVBOs( false ); + tess.surfaceStages = tess.surfaceShader->stages; + tess.surfaceLastStage = tess.surfaceShader->lastStage; } else { - state = nullptr; + /* No code is using this on purpose, this is kept because of the + scary comment above saying: - tess.surfaceShader = nullptr; + > A surface may be forced to perform a Tess_End due to overflow. */ tess.surfaceStages = nullptr; tess.surfaceLastStage = nullptr; - Tess_MapVBOs( false ); } - tess.lightShader = lightShader; - - tess.stageIteratorFunc = stageIteratorFunc; - tess.stageIteratorFunc2 = stageIteratorFunc2; + Tess_MapVBOs( false ); if ( !tess.stageIteratorFunc ) { Sys::Error( "tess.stageIteratorFunc == NULL" ); } - if ( state != nullptr && state->isSky ) - { - tess.stageIteratorFunc = &Tess_StageIteratorSky; - } - - tess.skipTangentSpaces = skipTangentSpaces; - tess.lightmapNum = lightmapNum; - tess.fogNum = fogNum; - tess.bspSurface = bspSurface; - if ( r_logFile->integer ) { // don't just call LogComment, or we will get diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index 125d6bd7c7..1af486e9b3 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -5224,6 +5224,13 @@ static void FinishStages() // We should cancel overBrightBits if there is no light stage. stage->shaderHasNoLight = shaderHasNoLight; + // We should not cancel overbright on decals. + if ( shader.sort == Util::ordinal(shaderSort_t::SS_DECAL) ) + { + // HACK: Reuse that boolean. + stage->shaderHasNoLight = false; + } + // Available textures. bool hasNormalMap = stage->bundle[ TB_NORMALMAP ].image[ 0 ] != nullptr; bool hasHeightMap = stage->bundle[ TB_HEIGHTMAP ].image[ 0 ] != nullptr;