Skip to content

Commit

Permalink
#5565: Export spectrum
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 25, 2021
1 parent fec4baa commit e0fb7ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -89,6 +89,12 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
}
}

// Spectrum
if (shaderTemplate.getSpectrum() != 0)
{
stream << "\tspectrum " << shaderTemplate.getSpectrum() << "\n";
}

for (const auto& layer : shaderTemplate.getLayers())
{
stream << "\t{\n";
Expand Down
21 changes: 21 additions & 0 deletions test/MaterialExport.cpp
Expand Up @@ -194,4 +194,25 @@ TEST_F(MaterialExportTest, Sort)
expectDefinitionDoesNotContain(material, "sort");
}

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

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

for (int i = -50; i < 50; ++i)
{
material->setSpectrum(i);

if (i != 0)
{
expectDefinitionContains(material, fmt::format("spectrum {0}", i));
}
else // spectrum 0 is the default, doesn't need to be declared
{
expectDefinitionDoesNotContain(material, "spectrum");
}
}
}

}

0 comments on commit e0fb7ce

Please sign in to comment.