Skip to content

Commit

Permalink
#6052: Extend material parser tests to cover the problems when parsin…
Browse files Browse the repository at this point in the history
…g mirrorRenderMap and remoteRenderMap stages.
  • Loading branch information
codereader committed Aug 5, 2022
1 parent 74c8f3d commit 32573ca
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
64 changes: 64 additions & 0 deletions test/Materials.cpp
Expand Up @@ -1535,6 +1535,70 @@ TEST_F(MaterialsTest, ParseNoShadowsFlag)
EXPECT_EQ(material->getMaterialFlags() & Material::FLAG_NOSHADOWS, Material::FLAG_NOSHADOWS) << "Material should have noshadows set";
}

TEST_F(MaterialsTest, MaterialParserRemoteRenderMap)
{
// Remote Render Map without map expression
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/remoteRenderMap1");
EXPECT_TRUE(material) << "Could not find the material textures/parsertest/remoteRenderMap1";

auto layers = material->getAllLayers();

EXPECT_EQ(layers.at(0)->getType(), IShaderLayer::BLEND);
EXPECT_EQ(layers.at(0)->getMapType(), IShaderLayer::MapType::RemoteRenderMap);
EXPECT_EQ(layers.at(0)->getRenderMapSize(), Vector2(232, 232));
EXPECT_FALSE(layers.at(0)->getMapExpression());

// Remote Render Map with map expression
material = GlobalMaterialManager().getMaterial("textures/parsertest/remoteRenderMap2");
EXPECT_TRUE(material) << "Could not find the material textures/parsertest/remoteRenderMap2";

layers = material->getAllLayers();

EXPECT_EQ(layers.at(0)->getType(), IShaderLayer::BLEND);
EXPECT_EQ(layers.at(0)->getMapType(), IShaderLayer::MapType::RemoteRenderMap);
EXPECT_EQ(layers.at(0)->getRenderMapSize(), Vector2(256, 128));
EXPECT_TRUE(layers.at(0)->getMapExpression());
EXPECT_EQ(layers.at(0)->getMapExpression()->getExpressionString(), "textures/common/mirror.tga");
}

TEST_F(MaterialsTest, MaterialParserMirrorRenderMap)
{
// Mirror Render Map without map expression
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/mirrorRenderMap1");
EXPECT_TRUE(material) << "Could not find the material textures/parsertest/mirrorRenderMap1";

auto layers = material->getAllLayers();

EXPECT_EQ(layers.at(0)->getType(), IShaderLayer::BLEND);
EXPECT_EQ(layers.at(0)->getMapType(), IShaderLayer::MapType::MirrorRenderMap);
EXPECT_EQ(layers.at(0)->getRenderMapSize(), Vector2(256, 128));
EXPECT_FALSE(layers.at(0)->getMapExpression());

// Mirror Render Map with map expression
material = GlobalMaterialManager().getMaterial("textures/parsertest/mirrorRenderMap2");
EXPECT_TRUE(material) << "Could not find the material textures/parsertest/mirrorRenderMap2";

layers = material->getAllLayers();

EXPECT_EQ(layers.at(0)->getType(), IShaderLayer::BLEND);
EXPECT_EQ(layers.at(0)->getMapType(), IShaderLayer::MapType::MirrorRenderMap);
EXPECT_EQ(layers.at(0)->getRenderMapSize(), Vector2(256, 128));
EXPECT_TRUE(layers.at(0)->getMapExpression());
EXPECT_EQ(layers.at(0)->getMapExpression()->getExpressionString(), "textures/common/mirror.tga");

// Mirror Render Map without dimensions
material = GlobalMaterialManager().getMaterial("textures/parsertest/mirrorRenderMap3");
EXPECT_TRUE(material) << "Could not find the material textures/parsertest/mirrorRenderMap3";

layers = material->getAllLayers();

EXPECT_EQ(layers.at(0)->getType(), IShaderLayer::BLEND);
EXPECT_EQ(layers.at(0)->getMapType(), IShaderLayer::MapType::MirrorRenderMap);
EXPECT_EQ(layers.at(0)->getRenderMapSize(), Vector2(0, 0));
EXPECT_TRUE(layers.at(0)->getMapExpression());
EXPECT_EQ(layers.at(0)->getMapExpression()->getExpressionString(), "textures/common/mirror.tga");
}

TEST_F(MaterialsTest, ShaderExpressionEvaluation)
{
constexpr std::size_t TimeInMilliseconds = 200;
Expand Down
44 changes: 44 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -1033,4 +1033,48 @@ textures/parsertest/noshadowsflag
glass
noShadows
diffusemap _black
}

textures/parsertest/remoteRenderMap1
{
{
red Parm0
green Parm1
blue Parm2
remoteRenderMap 232 232 // width / height of render image, ie resolution of screen
}
}

textures/parsertest/remoteRenderMap2
{
{
map textures/common/mirror.tga
remoteRenderMap 256 128
}
}

textures/parsertest/mirrorRenderMap1
{
{
blend blend
mirrorRenderMap 256 128
}
}

textures/parsertest/mirrorRenderMap2
{
{
blend blend
mirrorRenderMap 256 128
map textures/common/mirror.tga
}
}

textures/parsertest/mirrorRenderMap3
{
{
blend blend
map textures/common/mirror.tga
mirrorRenderMap
}
}

0 comments on commit 32573ca

Please sign in to comment.