Skip to content

Commit

Permalink
Merge branch 'master' into for-0.55.0/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 31, 2024
2 parents c4b4421 + 31eef16 commit cae0102
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/engine/renderer/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion src/engine/renderer/glsl_source/computeLight_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
4 changes: 2 additions & 2 deletions src/engine/renderer/glsl_source/lightMapping_fp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
51 changes: 26 additions & 25 deletions src/engine/renderer/tr_shade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cae0102

Please sign in to comment.