Skip to content

Commit af66f2b

Browse files
committed
Fix ropes not being translucent
1 parent 8958925 commit af66f2b

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

sp/src/materialsystem/stdshaders/splinerope.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ BEGIN_VS_SHADER( SDK_Cable_DX9, "Help for SplineRope" )
4949
{
5050
bool bShaderSrgbRead = ( IsX360() && params[SHADERSRGBREAD360]->GetIntValue() );
5151
bool bShadowDepth = ( params[SHADOWDEPTH]->GetIntValue() != 0 );
52+
53+
#ifdef MAPBASE
54+
BlendType_t nBlendType = EvaluateBlendRequirements( BASETEXTURE, true );
55+
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ); //dest alpha is free for special use
56+
#else
57+
bool bFullyOpaque = true;
58+
#endif
59+
5260
SHADOW_STATE
5361
{
5462
// draw back-facing because of yaw spin
@@ -65,8 +73,19 @@ BEGIN_VS_SHADER( SDK_Cable_DX9, "Help for SplineRope" )
6573
}
6674
else
6775
{
76+
#ifdef MAPBASE
77+
if (IS_FLAG_SET( MATERIAL_VAR_TRANSLUCENT ))
78+
{
79+
pShaderShadow->EnableDepthWrites( false );
80+
pShaderShadow->EnableBlending( true );
81+
pShaderShadow->BlendFunc( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA );
82+
}
83+
84+
pShaderShadow->EnableAlphaTest( IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) );
85+
#endif
86+
6887
// We need to write to dest alpha for depth feathering.
69-
pShaderShadow->EnableAlphaWrites( true );
88+
pShaderShadow->EnableAlphaWrites( bFullyOpaque );
7089

7190
// base texture
7291
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
@@ -150,7 +169,7 @@ BEGIN_VS_SHADER( SDK_Cable_DX9, "Help for SplineRope" )
150169
if ( g_pHardwareConfig->SupportsPixelShaders_2_b() )
151170
{
152171
DECLARE_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20b );
153-
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, pShaderAPI->ShouldWriteDepthToDestAlpha() );
172+
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bFullyOpaque && pShaderAPI->ShouldWriteDepthToDestAlpha() );
154173
//SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z );
155174
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
156175
SET_DYNAMIC_PIXEL_SHADER( sdk_splinerope_ps20b );

0 commit comments

Comments
 (0)