Skip to content

Commit

Permalink
renderer: fix legacy dynamic light intensity
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 25, 2024
1 parent bfa7b90 commit 7b5abf5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,7 @@ GLShader_forwardLighting_omniXYZ::GLShader_forwardLighting_omniXYZ( GLShaderMana
u_ViewOrigin( this ),
u_LightOrigin( this ),
u_LightColor( this ),
u_InverseLightFactor( this ),
u_LightRadius( this ),
u_LightScale( this ),
u_LightAttenuationMatrix( this ),
Expand Down Expand Up @@ -1768,6 +1769,7 @@ GLShader_forwardLighting_projXYZ::GLShader_forwardLighting_projXYZ( GLShaderMana
u_ViewOrigin( this ),
u_LightOrigin( this ),
u_LightColor( this ),
u_InverseLightFactor( this ),
u_LightRadius( this ),
u_LightScale( this ),
u_LightAttenuationMatrix( this ),
Expand Down Expand Up @@ -1828,6 +1830,7 @@ GLShader_forwardLighting_directionalSun::GLShader_forwardLighting_directionalSun
u_ViewOrigin( this ),
u_LightDir( this ),
u_LightColor( this ),
u_InverseLightFactor( this ),
u_LightRadius( this ),
u_LightScale( this ),
u_LightAttenuationMatrix( this ),
Expand Down
3 changes: 3 additions & 0 deletions src/engine/renderer/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,7 @@ class GLShader_forwardLighting_omniXYZ :
public u_ViewOrigin,
public u_LightOrigin,
public u_LightColor,
public u_InverseLightFactor,
public u_LightRadius,
public u_LightScale,
public u_LightAttenuationMatrix,
Expand Down Expand Up @@ -2409,6 +2410,7 @@ class GLShader_forwardLighting_projXYZ :
public u_ViewOrigin,
public u_LightOrigin,
public u_LightColor,
public u_InverseLightFactor,
public u_LightRadius,
public u_LightScale,
public u_LightAttenuationMatrix,
Expand Down Expand Up @@ -2447,6 +2449,7 @@ class GLShader_forwardLighting_directionalSun :
public u_ViewOrigin,
public u_LightDir,
public u_LightColor,
public u_InverseLightFactor,
public u_LightRadius,
public u_LightScale,
public u_LightAttenuationMatrix,
Expand Down
2 changes: 2 additions & 0 deletions src/engine/renderer/glsl_source/forwardLighting_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ uniform vec3 u_LightDir;
uniform vec3 u_LightOrigin;
#endif
uniform vec3 u_LightColor;
uniform float u_InverseLightFactor;
uniform float u_LightRadius;
uniform float u_LightScale;
uniform float u_AlphaThreshold;
Expand Down Expand Up @@ -1006,6 +1007,7 @@ void main()
color.rgb *= attenuationZ;
#endif
color.rgb *= abs(u_LightScale);
color.rgb *= u_InverseLightFactor;
color.rgb *= shadow;

color.rgb *= var_Color.rgb;
Expand Down
7 changes: 5 additions & 2 deletions src/engine/renderer/tr_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,11 @@ void RE_AddDynamicLightToSceneET( const vec3_t org, float radius, float intensit
light->l.color[ 1 ] = g;
light->l.color[ 2 ] = b;

// Cancel overBright on dynamic lights.
VectorScale( light->l.color, tr.mapInverseLightFactor, light->l.color );
if ( r_dynamicLightRenderer.Get() == Util::ordinal( dynamicLightRenderer_t::TILED ) )
{
// Cancel overBright on dynamic lights.
VectorScale( light->l.color, tr.mapInverseLightFactor, light->l.color );
}

light->l.inverseShadows = (flags & REF_INVERSE_DLIGHT) != 0;
light->l.noShadows = !r_dynamicLightCastShadows->integer && !light->l.inverseShadows;
Expand Down
9 changes: 9 additions & 0 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,9 @@ static void Render_forwardLighting_DBS_omni( shaderStage_t *pStage,

gl_forwardLightingShader_omniXYZ->SetUniform_AlphaTest( pStage->stateBits );

// u_InverseLightFactor
gl_forwardLightingShader_omniXYZ->SetUniform_InverseLightFactor( tr.mapInverseLightFactor );

// bind u_HeightMap
if ( pStage->enableReliefMapping )
{
Expand Down Expand Up @@ -1497,6 +1500,9 @@ static void Render_forwardLighting_DBS_proj( shaderStage_t *pStage,

gl_forwardLightingShader_projXYZ->SetUniform_AlphaTest( pStage->stateBits );

// u_InverseLightFactor
gl_forwardLightingShader_projXYZ->SetUniform_InverseLightFactor( tr.mapInverseLightFactor );

// bind u_HeightMap
if ( pStage->enableReliefMapping )
{
Expand Down Expand Up @@ -1658,6 +1664,9 @@ static void Render_forwardLighting_DBS_directional( shaderStage_t *pStage, trRef

gl_forwardLightingShader_directionalSun->SetUniform_AlphaTest( pStage->stateBits );

// u_InverseLightFactor
gl_forwardLightingShader_directionalSun->SetUniform_InverseLightFactor( tr.mapInverseLightFactor );

// bind u_HeightMap
if ( pStage->enableReliefMapping )
{
Expand Down

0 comments on commit 7b5abf5

Please sign in to comment.