Skip to content

Commit 023d755

Browse files
committed
fix perseus door
1 parent 331e85c commit 023d755

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

src/engine/renderer/tr_shader.cpp

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5239,35 +5239,57 @@ static void FinishStages()
52395239
? gl_shaderManager.getDeformShaderIndex( shader.deforms, shader.numDeforms )
52405240
: 0;
52415241

5242+
bool isOpaqueShader = false;
5243+
52425244
for ( size_t s = 0; s < numStages; s++ )
52435245
{
52445246
shaderStage_t *stage = &stages[ s ];
52455247

52465248
stage->deformIndex = deformIndex;
52475249

5248-
// We should cancel overbright if there is no light stage.
5249-
stage->cancelOverBright = shaderHasNoLight;
5250+
// SRC1 and DST0 are reset to zero in ParseStage (no blending).
5251+
bool isOpaque = !( stage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) );
5252+
5253+
// A shader is not opaque if all stages are not opaques.
5254+
isOpaqueShader |= isOpaque;
5255+
5256+
bool blendFunc_srcDstColor = ( stage->stateBits & GLS_SRCBLEND_BITS ) == GLS_SRCBLEND_DST_COLOR;
52505257

52515258
if ( shaderHasNoLight )
52525259
{
5253-
// We should not cancel overbright if there is no light and it's not using blendFunc dst_color.
5254-
bool blendFunc_dstColor = ( stage->stateBits & GLS_SRCBLEND_BITS ) == GLS_SRCBLEND_DST_COLOR;
5260+
// We should cancel overbright if there is no light stage, unless it's using blendFunc dst_color.
5261+
stage->cancelOverBright = !blendFunc_srcDstColor;
52555262

5256-
if ( blendFunc_dstColor )
5257-
{
5258-
stage->cancelOverBright = false;
5259-
}
5260-
5261-
// We should not cancel overbright if that's a non-opaque decal.
52625263
bool isDecal = shader.sort == Util::ordinal(shaderSort_t::SS_DECAL);
5263-
// SRC1 and DST0 are reset to zero in ParseStage (no blending).
5264-
bool isOpaque = !( stage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) );
52655264

52665265
if ( isDecal )
52675266
{
5267+
// We should not cancel overbright if that's a non-opaque decal.
52685268
stage->cancelOverBright = isOpaque;
52695269
}
52705270
}
5271+
else
5272+
{
5273+
if ( isOpaqueShader )
5274+
{
5275+
// We we should not cancel overbright if the light stage is applied on an opaque surface;
5276+
stage->cancelOverBright = false;
5277+
}
5278+
else
5279+
{
5280+
bool blendFunc_add = ( stage->stateBits & GLS_SRCBLEND_BITS ) == GLS_SRCBLEND_ONE
5281+
&& ( stage->stateBits & GLS_DSTBLEND_BITS ) == GLS_DSTBLEND_ONE;
5282+
5283+
if ( blendFunc_add )
5284+
{
5285+
stage->cancelOverBright = true;
5286+
}
5287+
else
5288+
{
5289+
stage->cancelOverBright = false;
5290+
}
5291+
}
5292+
}
52715293

52725294
// Available textures.
52735295
bool hasNormalMap = stage->bundle[ TB_NORMALMAP ].image[ 0 ] != nullptr;

0 commit comments

Comments
 (0)