Skip to content

Commit

Permalink
#5565: Export private polygon offset
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 26, 2021
1 parent 58a32a9 commit ff4b119
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -249,6 +249,12 @@ std::ostream& operator<<(std::ostream& stream, Doom3ShaderLayer& layer)
}
}

// Private Polygon Offset
if (layer.getPrivatePolygonOffset() != 0)
{
stream << "\t\tprivatePolygonOffset " << layer.getPrivatePolygonOffset() << "\n";
}

stream << "\t}\n";

return stream;
Expand Down
21 changes: 19 additions & 2 deletions test/MaterialExport.cpp
Expand Up @@ -786,13 +786,30 @@ TEST_F(MaterialExportTest, StageVertexColours)
// Make use of color shortcut
layer = material->getEditableLayer(material->addLayer(IShaderLayer::BLEND));
layer->setVertexColourMode(IShaderLayer::VERTEX_COLOUR_MULTIPLY);
expectDefinitionContains(material, { "vertexColor" });
expectDefinitionContains(material, "vertexColor");

layer->setVertexColourMode(IShaderLayer::VERTEX_COLOUR_INVERSE_MULTIPLY);
expectDefinitionContains(material, { "inverseVertexColor" });
expectDefinitionContains(material, "inverseVertexColor");

layer->setVertexColourMode(IShaderLayer::VERTEX_COLOUR_NONE);
expectDefinitionDoesNotContainAnyOf(material, { "vertexColor", "inverseVertexColor" });
}

TEST_F(MaterialExportTest, StagePrivatePolygonOffset)
{
auto material = GlobalMaterialManager().getMaterial("textures/exporttest/empty");

EXPECT_EQ(string::trim_copy(material->getDefinition()), "");

auto layer = material->getEditableLayer(material->addLayer(IShaderLayer::BLEND));
layer->setPrivatePolygonOffset(0.1);
expectDefinitionContains(material, "privatePolygonOffset 0.1");

layer->setPrivatePolygonOffset(-15.7);
expectDefinitionContains(material, "privatePolygonOffset -15.7");

layer->setPrivatePolygonOffset(0);
expectDefinitionDoesNotContain(material, "privatePolygonOffset");
}

}
9 changes: 9 additions & 0 deletions test/Materials.cpp
Expand Up @@ -1204,4 +1204,13 @@ TEST_F(MaterialsTest, MaterialParserStageVertexColours)
EXPECT_FALSE(material->getAllLayers().at(2)->getColourExpression(IShaderLayer::COMP_RGBA));
}

TEST_F(MaterialsTest, MaterialParserStagePrivatePolygonOffset)
{
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/transform/notransform");
EXPECT_EQ(material->getAllLayers().at(0)->getPrivatePolygonOffset(), 0.0f);

material = GlobalMaterialManager().getMaterial("textures/parsertest/privatePolygonOffset");
EXPECT_EQ(material->getAllLayers().at(0)->getPrivatePolygonOffset(), -45.9f);
}

}
9 changes: 9 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -877,3 +877,12 @@ textures/parsertest/vertexcolours/combinations2
alpha time
}
}

textures/parsertest/privatePolygonOffset
{
{
blend diffusemap
map _white
privatePolygonOffset -45.9
}
}

0 comments on commit ff4b119

Please sign in to comment.