Permalink
Browse files

Fix blendfunc parser and and don't reset depth write on opaque shaders.

  • Loading branch information...
1 parent 7da45af commit f0037f65e63934f519f4722414de58b72c5a44b2 @gimhael gimhael committed Mar 7, 2016
Showing with 13 additions and 62 deletions.
  1. +13 −62 daemon/src/engine/renderer/tr_shader.cpp
@@ -1814,60 +1814,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
}
}
- // blendfunc <srcFactor> <dstFactor>
- // or blendfunc <add|filter|blend>
- else if ( !Q_stricmp( token, "blendfunc" ) )
- {
- token = COM_ParseExt2( text, false );
-
- if ( token[ 0 ] == 0 )
- {
- Log::Warn("missing parm for blendFunc in shader '%s'", shader.name );
- continue;
- }
-
- // check for "simple" blends first
- if ( !Q_stricmp( token, "add" ) )
- {
- blendSrcBits = GLS_SRCBLEND_ONE;
- blendDstBits = GLS_DSTBLEND_ONE;
- }
- else if ( !Q_stricmp( token, "filter" ) )
- {
- blendSrcBits = GLS_SRCBLEND_DST_COLOR;
- blendDstBits = GLS_DSTBLEND_ZERO;
- }
- else if ( !Q_stricmp( token, "blend" ) )
- {
- blendSrcBits = GLS_SRCBLEND_SRC_ALPHA;
- blendDstBits = GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
- }
- else
- {
- // complex double blends
- blendSrcBits = NameToSrcBlendMode( token );
-
- token = COM_ParseExt2( text, false );
-
- if ( token[ 0 ] == 0 )
- {
- Log::Warn("missing parm for blendFunc in shader '%s'", shader.name );
- continue;
- }
-
- blendDstBits = NameToDstBlendMode( token );
- }
-
- // clear depth mask for blended surfaces
- if ( !depthMaskExplicit )
- {
- depthMaskBits = 0;
- }
- }
- // blend <srcFactor> , <dstFactor>
- // or blend <add | filter | blend>
- // or blend <diffusemap | bumpmap | specularmap>
- else if ( !Q_stricmp( token, "blend" ) )
+ // blend[func] <srcFactor> [,] <dstFactor>
+ // or blend[func] <add | filter | blend>
+ // or blend[func] <diffusemap | bumpmap | specularmap>
+ else if ( !Q_stricmp( token, "blendfunc" ) ||
+ !Q_stricmp( token, "blend" ) )
{
token = COM_ParseExt2( text, false );
@@ -1931,15 +1882,10 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
token = COM_ParseExt2( text, false );
- if ( token[ 0 ] != ',' )
- {
- Log::Warn("expecting ',', found '%s' instead for blend in shader '%s'", token,
- shader.name );
- continue;
+ if ( !Q_stricmp(token, "," ) ) {
+ token = COM_ParseExt2( text, false );
}
- token = COM_ParseExt2( text, false );
-
if ( token[ 0 ] == 0 )
{
Log::Warn("missing parm for blend in shader '%s'", shader.name );
@@ -1950,7 +1896,12 @@ static bool ParseStage( shaderStage_t *stage, const char **text )
}
// clear depth mask for blended surfaces
- if ( !depthMaskExplicit && stage->type == stageType_t::ST_COLORMAP )
+ if ( !depthMaskExplicit &&
+ (stage->type == stageType_t::ST_COLORMAP ||
+ stage->type == stageType_t::ST_DIFFUSEMAP) &&
+ blendSrcBits != 0 && blendDstBits != 0
+ && !(blendSrcBits == GLS_SRCBLEND_ONE &&
+ blendDstBits == GLS_DSTBLEND_ZERO) )
{
depthMaskBits = 0;
}

0 comments on commit f0037f6

Please sign in to comment.