Navigation Menu

Skip to content

Commit

Permalink
Fix blendfunc parser and and don't reset depth write on opaque shaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
gimhael committed Mar 7, 2016
1 parent 7da45af commit f0037f6
Showing 1 changed file with 13 additions and 62 deletions.
75 changes: 13 additions & 62 deletions daemon/src/engine/renderer/tr_shader.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand All @@ -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;
}
Expand Down

0 comments on commit f0037f6

Please sign in to comment.