Skip to content

Commit

Permalink
Simplify material test suite
Browse files Browse the repository at this point in the history
- Split channel.mtlx into separate documents for each node.
- Remove test materials for nodes with graph definitions.
- Reduce coupling of unit tests with material examples.
  • Loading branch information
jstone-lucasfilm committed Oct 20, 2024
1 parent f6355a6 commit d285d2f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 98 deletions.
1 change: 0 additions & 1 deletion libraries/stdlib/stdlib_ng.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -4386,7 +4386,6 @@
</combine4>
</nodegraph>


<!-- ======================================================================== -->
<!-- Conditional nodes -->
<!-- ======================================================================== -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,39 +62,4 @@
</combine2>
<output name="out" type="vector4" nodename="combine1" />
</nodegraph>
<nodegraph name="extract_color3">
<extract name="extract1" type="float">
<input name="in" type="color3" value="0.0, 0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_color4">
<extract name="extract1" type="float">
<input name="in" type="color4" value="0.0000, 0.2500, 0.7500, 1.0" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector2">
<extract name="extract1" type="float">
<input name="in" type="vector2" value="0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector3">
<extract name="extract1" type="float">
<input name="in" type="vector3" value="0.0, 0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector4">
<extract name="extract1" type="float">
<input name="in" type="vector4" value="0.0, 0.2500, 0.7500, 1.0" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
</materialx>
38 changes: 38 additions & 0 deletions resources/Materials/TestSuite/stdlib/channel/extract.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<materialx version="1.39">
<nodegraph name="extract_color3">
<extract name="extract1" type="float">
<input name="in" type="color3" value="0.0, 0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_color4">
<extract name="extract1" type="float">
<input name="in" type="color4" value="0.0000, 0.2500, 0.7500, 1.0" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector2">
<extract name="extract1" type="float">
<input name="in" type="vector2" value="0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector3">
<extract name="extract1" type="float">
<input name="in" type="vector3" value="0.0, 0.5000, 1.0000" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
<nodegraph name="extract_vector4">
<extract name="extract1" type="float">
<input name="in" type="vector4" value="0.0, 0.2500, 0.7500, 1.0" />
<input name="index" type="integer" value="1" />
</extract>
<output name="out" type="float" nodename="extract1" />
</nodegraph>
</materialx>
25 changes: 0 additions & 25 deletions resources/Materials/TestSuite/stdlib/compositing/compositing.mtlx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- burn
- dodge
- screen
- overlay
- disjointover
- mask
- matte
Expand Down Expand Up @@ -181,30 +180,6 @@
</screen>
<output name="out" type="color4" nodename="screen1" />
</nodegraph>
<nodegraph name="overlay_float">
<overlay name="overlay1" type="float">
<input name="fg" type="float" value="0.2" />
<input name="bg" type="float" value="0.6" />
<input name="mix" type="float" value="0.5000" />
</overlay>
<output name="out" type="float" nodename="overlay1" />
</nodegraph>
<nodegraph name="overlay_color3">
<overlay name="overlay1" type="color3">
<input name="fg" type="color3" value="0.2, 0.6, 0.6" />
<input name="bg" type="color3" value="0.8, 0.2, 0.4" />
<input name="mix" type="float" value="0.5000" />
</overlay>
<output name="out" type="color3" nodename="overlay1" />
</nodegraph>
<nodegraph name="overlay_color4">
<overlay name="overlay1" type="color4">
<input name="fg" type="color4" value="0.6, 0.8, 0.8, 1.0" />
<input name="bg" type="color4" value="0.6, 0.2, 0.4, 1.0" />
<input name="mix" type="float" value="0.5000" />
</overlay>
<output name="out" type="color4" nodename="overlay1" />
</nodegraph>
<nodegraph name="disjointover_color4">
<disjointover name="disjointover1" type="color4">
<input name="fg" type="color4" value="0.5000, 1.0000, 0.0, 1.0" />
Expand Down
37 changes: 0 additions & 37 deletions source/MaterialXTest/MaterialXCore/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,43 +627,6 @@ TEST_CASE("Organization", "[nodegraph]")
CHECK(nodeGraph->getBackdrops().empty());
}

TEST_CASE("Tokens", "[nodegraph]")
{
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();
mx::DocumentPtr stdlib = mx::createDocument();
mx::loadLibraries({ "libraries" }, searchPath, stdlib);

mx::DocumentPtr doc = mx::createDocument();
mx::readFromXmlFile(doc, "resources/Materials/TestSuite/stdlib/texture/tokenGraph.mtlx", searchPath);

mx::StringVec graphNames = { "Tokenized_Image_2k_png", "Tokenized_Image_4k_jpg" };
mx::StringVec resolutionStrings = { "2k", "4k" };
mx::StringVec extensionStrings = { "png", "jpg" };
for (size_t i=0; i<graphNames.size(); i++)
{
mx::NodeGraphPtr graph = doc->getNodeGraph(graphNames[i]);
REQUIRE(graph);
std::vector<mx::TokenPtr> tokens = graph->getActiveTokens();

mx::NodePtr imagePtr = graph->getNode("tiledimage");
REQUIRE(imagePtr);

mx::InputPtr input = imagePtr->getInput("file");
REQUIRE(input);

// Test file name substitution creation.
mx::StringResolverPtr resolver = input->createStringResolver();
const mx::StringMap& substitutions = resolver->getFilenameSubstitutions();
const std::string DELIMITER_PREFIX("[");
const std::string DELIMITER_POSTFIX("]");
for (auto token : tokens)
{
const std::string tokenString = DELIMITER_PREFIX + token->getName() + DELIMITER_POSTFIX;
REQUIRE(substitutions.count(tokenString));
}
}
}

TEST_CASE("Node Definition Creation", "[nodedef]")
{
mx::FileSearchPath searchPath = mx::getDefaultDataSearchPath();
Expand Down

0 comments on commit d285d2f

Please sign in to comment.