From f0037f65e63934f519f4722414de58b72c5a44b2 Mon Sep 17 00:00:00 2001 From: Matthias Bentrup Date: Mon, 7 Mar 2016 10:52:01 +0100 Subject: [PATCH] Fix blendfunc parser and and don't reset depth write on opaque shaders. --- daemon/src/engine/renderer/tr_shader.cpp | 75 ++++-------------------- 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/daemon/src/engine/renderer/tr_shader.cpp b/daemon/src/engine/renderer/tr_shader.cpp index b2dde65b06d..7b12c1a193c 100644 --- a/daemon/src/engine/renderer/tr_shader.cpp +++ b/daemon/src/engine/renderer/tr_shader.cpp @@ -1814,60 +1814,11 @@ static bool ParseStage( shaderStage_t *stage, const char **text ) } } - // blendfunc - // or blendfunc - 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 , - // or blend - // or blend - else if ( !Q_stricmp( token, "blend" ) ) + // blend[func] [,] + // or blend[func] + // or blend[func] + 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; }