Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UDIM example and fix UDIM bug in MaterialXGraphEditor #2113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions resources/Geometry/udim_cube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This file uses centimeters as units for non-parametric coordinates.
g
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
vt 0.99 0.01
vt 0.99 1.01
vt 1.01 0.01
vt 2.01 0.99
vt 2.01 1.01
vt 1.99 0.99
vt 1.01 1.01
vt 2.99 2.01
vt 1.01 1.99
vt 1.99 1.99
vt 2.99 0.01
vt 2.99 0.99
vt 0.01 0.01
vt 0.01 0.99
vt 2.01 0.01
vt 0.99 1.99
vt 1.99 0.01
vt 0.01 1.01
vt 0.01 1.99
vt 0.99 0.99
vt 2.01 2.01
vt 1.99 1.01
vt 1.01 0.99
vt 2.99 1.
g
f 1/18 2/2 4/16 3/19
f 3/3 4/17 6/6 5/23
f 5/5 6/24 8/8 7/21
f 7/7 8/22 2/10 1/9
f 2/15 8/11 6/12 4/4
f 7/13 1/1 3/20 5/14
Binary file added resources/Images/udim_bunny/grid_1001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Images/udim_bunny/grid_1002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Images/udim_bunny/grid_1003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Images/udim_bunny/grid_1011.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Images/udim_bunny/grid_1012.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/Images/udim_bunny/grid_1013.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions resources/Materials/TestSuite/stdlib/udim/multi_udim_bunny.mtlx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<materialx version="1.38">
<image name="image_color" type="color3">
<input name="file" type="filename" value="resources/Images/udim_bunny/grid_<UDIM>.png" colorspace="srgb_texture" />
</image>
<geominfo name="G_Bunny" geom="/">
<geomprop name="udimset" type="stringarray" value="1001, 1002, 1003, 1011, 1012, 1013" />
</geominfo>
<standard_surface name="S_Bunny" type="surfaceshader">
<input name="base_color" type="color3" nodename="image_color" />
</standard_surface>
<surfacematerial name="M_Bunny" type="material">
<input name="surfaceshader" type="surfaceshader" nodename="S_Bunny" />
</surfacematerial>
</materialx>
18 changes: 9 additions & 9 deletions source/MaterialXGraphEditor/RenderView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,6 @@ void RenderView::updateMaterials(mx::TypedElementPtr typedElem)
// Check for any udim set.
mx::ValuePtr udimSetValue = _document->getGeomPropValue(mx::UDIM_SET_PROPERTY);

// Skip material nodes without upstream shaders.
mx::NodePtr node = typedElem ? typedElem->asA<mx::Node>() : nullptr;
if (node &&
node->getCategory() == mx::SURFACE_MATERIAL_NODE_STRING &&
mx::getShaderNodes(node).empty())
{
typedElem = nullptr;
}

// Create new materials.
if (!typedElem)
{
Expand All @@ -422,6 +413,15 @@ void RenderView::updateMaterials(mx::TypedElementPtr typedElem)
}
}

// Skip material nodes without upstream shaders.
mx::NodePtr node = typedElem ? typedElem->asA<mx::Node>() : nullptr;
if (node &&
node->getCategory() == mx::SURFACE_MATERIAL_NODE_STRING &&
mx::getShaderNodes(node).empty())
{
typedElem = nullptr;
}

mx::TypedElementPtr udimElement = nullptr;
mx::NodePtr materialNode = nullptr;
if (typedElem)
Expand Down