Skip to content

Commit

Permalink
#5567: Some materials are using _white.tga instead of _white in frob …
Browse files Browse the repository at this point in the history
…stages
  • Loading branch information
codereader committed Apr 2, 2021
1 parent 079e9bd commit 699a3fd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libs/materials/FrobStageSetup.h
Expand Up @@ -3,6 +3,7 @@
#include "i18n.h"
#include "ishaders.h"
#include "ishaderlayer.h"
#include "string/predicate.h"

namespace shaders
{
Expand Down Expand Up @@ -128,8 +129,8 @@ class FrobStageSetup
continue;
}

// map _white
if (!layer->getMapExpression() || layer->getMapExpression()->getExpressionString() != WhiteBlendMap)
// map _white (or _white.tga)
if (!layer->getMapExpression() || !string::starts_with(layer->getMapExpression()->getExpressionString(), WhiteBlendMap))
{
continue;
}
Expand Down
6 changes: 6 additions & 0 deletions test/Materials.cpp
Expand Up @@ -1408,6 +1408,11 @@ TEST_F(MaterialsTest, MaterialFrobStageDetection)
EXPECT_TRUE(shaders::FrobStageSetup::IsPresent(material));
EXPECT_TRUE(shaders::FrobStageSetup::HasAdditiveDiffuseStage(material));
EXPECT_TRUE(shaders::FrobStageSetup::HasWhiteBlendStage(material));

material = GlobalMaterialManager().getMaterial("textures/parsertest/frobstage_present2");
EXPECT_TRUE(shaders::FrobStageSetup::IsPresent(material));
EXPECT_TRUE(shaders::FrobStageSetup::HasAdditiveDiffuseStage(material));
EXPECT_TRUE(shaders::FrobStageSetup::HasWhiteBlendStage(material));

material = GlobalMaterialManager().getMaterial("textures/parsertest/frobstage_missing1");
EXPECT_FALSE(shaders::FrobStageSetup::IsPresent(material));
Expand Down Expand Up @@ -1486,6 +1491,7 @@ void checkFrobStageRemoval(const std::string& materialName)
TEST_F(MaterialsTest, MaterialFrobStageRemoval)
{
checkFrobStageRemoval("textures/parsertest/frobstage_present1");
checkFrobStageRemoval("textures/parsertest/frobstage_present2");
checkFrobStageRemoval("textures/parsertest/frobstage_missing1");
checkFrobStageRemoval("textures/parsertest/frobstage_missing2");
checkFrobStageRemoval("textures/parsertest/frobstage_missing3");
Expand Down
20 changes: 20 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -925,6 +925,26 @@ textures/parsertest/frobstage_present1
}
}

textures/parsertest/frobstage_present2 // is using _white.tga instead _white
{
qer_editorimage textures/numbers/0
diffusemap textures/numbers/0
bumpmap textures/numbers/1

{
if ( parm11 > 0 )
blend gl_dst_color, gl_one
map _white.tga
rgb 0.40 * parm11
}
{
if ( parm11 > 0 )
blend add
map textures/numbers/0
rgb 0.15 * parm11
}
}

textures/parsertest/frobstage_missing1
{
diffusemap textures/numbers/0
Expand Down

0 comments on commit 699a3fd

Please sign in to comment.