Skip to content

Commit

Permalink
#5565: Export texture filter
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 26, 2021
1 parent 6c6f55c commit bc16ae8
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
11 changes: 11 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -79,6 +79,17 @@ std::ostream& operator<<(std::ostream& stream, Doom3ShaderLayer& layer)
} // switch
}

// Texture Filter
if (layer.getStageFlags() & IShaderLayer::FLAG_FILTER_NEAREST)
{
stream << "\t\tnearest\n";
}

if (layer.getStageFlags() & IShaderLayer::FLAG_FILTER_LINEAR)
{
stream << "\t\tlinear\n";
}

stream << "\t}\n";

return stream;
Expand Down
24 changes: 24 additions & 0 deletions test/MaterialExport.cpp
Expand Up @@ -523,4 +523,28 @@ TEST_F(MaterialExportTest, StageMaps)
expectDefinitionContains(material, "soundMap waveform");
}

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

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

auto layer = material->getEditableLayer(material->addLayer(IShaderLayer::BLEND));
layer->setStageFlag(IShaderLayer::FLAG_FILTER_NEAREST);
expectDefinitionContains(material, "nearest");
expectDefinitionDoesNotContain(material, "linear");

layer->clearStageFlag(IShaderLayer::FLAG_FILTER_NEAREST);
expectDefinitionDoesNotContain(material, "nearest");
expectDefinitionDoesNotContain(material, "linear");

layer->setStageFlag(IShaderLayer::FLAG_FILTER_LINEAR);
expectDefinitionContains(material, "linear");
expectDefinitionDoesNotContain(material, "nearest");

layer->clearStageFlag(IShaderLayer::FLAG_FILTER_LINEAR);
expectDefinitionDoesNotContain(material, "nearest");
expectDefinitionDoesNotContain(material, "linear");
}

}
9 changes: 9 additions & 0 deletions test/Materials.cpp
Expand Up @@ -991,4 +991,13 @@ TEST_F(MaterialsTest, MaterialParserSurfaceFlags)
}
}

TEST_F(MaterialsTest, MaterialParserTextureFiltering)
{
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/texturefilter/nearest");
EXPECT_NE(material->getAllLayers().front()->getStageFlags() & IShaderLayer::FLAG_FILTER_NEAREST, 0);

material = GlobalMaterialManager().getMaterial("textures/parsertest/texturefilter/linear");
EXPECT_NE(material->getAllLayers().front()->getStageFlags() & IShaderLayer::FLAG_FILTER_LINEAR, 0);
}

}
53 changes: 53 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -545,3 +545,56 @@ textures/parsertest/surfaceflags/noimpact { noimpact }
textures/parsertest/surfaceflags/nodamage { nodamage }
textures/parsertest/surfaceflags/ladder { ladder }
textures/parsertest/surfaceflags/nosteps { nosteps }

textures/parsertest/texgen/normal
{
{
blend diffusemap
map _white
}
}

textures/parsertest/texgen/reflect
{
{
blend diffusemap
map _white
texgen reflect
}
}

textures/parsertest/texgen/skybox
{
{
blend diffusemap
map _white
texgen skybox
}
}

textures/parsertest/texgen/skybox
{
{
blend diffusemap
map _white
texgen skybox
}
}

textures/parsertest/texturefilter/nearest
{
{
blend diffusemap
map _white
nearest
}
}

textures/parsertest/texturefilter/linear
{
{
blend diffusemap
map _white
linear
}
}

0 comments on commit bc16ae8

Please sign in to comment.