Skip to content

Commit

Permalink
Add list of inputs when creating mtlx nodes (#1401)
Browse files Browse the repository at this point in the history
* add list of inputs when creating mtlx nodes

* fix incorrect arnold version and pass all the inputs

* free params memory

* add materialx texture offset test
  • Loading branch information
cpichard authored Jan 25, 2023
1 parent 6daf12c commit bcd25cf
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 10 deletions.
31 changes: 25 additions & 6 deletions render_delegate/node_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,16 @@ std::vector<AtNode*> HdArnoldNodeGraph::GetTerminals(const TfToken& terminalName

AtNode* HdArnoldNodeGraph::ReadMaterialNetwork(const HdMaterialNetwork& network)
{
//
ConnectedInputs connectedInputs;
for (const auto& relationship : network.relationships) {
connectedInputs[relationship.outputId].push_back(relationship.outputName);
}

std::vector<AtNode*> nodes;
nodes.reserve(network.nodes.size());
for (const auto& node : network.nodes) {
auto* n = ReadMaterialNode(node);
auto* n = ReadMaterialNode(node, connectedInputs);
if (n != nullptr) {
nodes.push_back(n);
}
Expand Down Expand Up @@ -611,7 +617,7 @@ AtNode* HdArnoldNodeGraph::ReadMaterialNetwork(const HdMaterialNetwork& network)
return entryPoint;
}

AtNode* HdArnoldNodeGraph::ReadMaterialNode(const HdMaterialNode& node)
AtNode* HdArnoldNodeGraph::ReadMaterialNode(const HdMaterialNode& node, const ConnectedInputs &connections)
{
const auto* nodeTypeStr = node.identifier.GetText();
bool isMaterialx = false;
Expand All @@ -624,7 +630,7 @@ AtNode* HdArnoldNodeGraph::ReadMaterialNode(const HdMaterialNode& node)

TF_DEBUG(HDARNOLD_MATERIAL)
.Msg("HdArnoldNodeGraph::ReadMaterial - node %s - type %s\n", node.path.GetText(), nodeType.c_str());
auto localNode = GetNode(node.path, nodeType);
auto localNode = GetNode(node.path, nodeType, connections);
if (localNode == nullptr || localNode->node == nullptr) {
return nullptr;
}
Expand Down Expand Up @@ -719,7 +725,7 @@ AtString HdArnoldNodeGraph::GetLocalNodeName(const SdfPath& path) const
return AtString(p.GetText());
}

HdArnoldNodeGraph::NodeDataPtr HdArnoldNodeGraph::GetNode(const SdfPath& path, const AtString& nodeType)
HdArnoldNodeGraph::NodeDataPtr HdArnoldNodeGraph::GetNode(const SdfPath& path, const AtString& nodeType, const ConnectedInputs &connectedInputs)
{
const auto nodeIt = _nodes.find(path);
// If the node already exists, we are checking if the node type is the same
Expand All @@ -743,7 +749,16 @@ HdArnoldNodeGraph::NodeDataPtr HdArnoldNodeGraph::GetNode(const SdfPath& path, c
}
const AtString nodeName = GetLocalNodeName(path);
// first check if there is a materialx shader associated to this node type
AtNode* node = GetMaterialxShader(nodeType, nodeName);
AtParamValueMap *params = AiParamValueMap();
auto inputsIt = connectedInputs.find(path);
if (inputsIt != connectedInputs.end()) {
for(const TfToken &attrName:inputsIt->second) {
AiParamValueMapSetStr(params, AtString(attrName.GetText()), AtString(""));
}
}
AtNode* node = GetMaterialxShader(nodeType, nodeName, params);
AiParamValueMapDestroy(params);
params = nullptr;

if (node == nullptr)
node = AiNode(_renderDelegate->GetUniverse(), nodeType, nodeName);
Expand All @@ -757,7 +772,7 @@ HdArnoldNodeGraph::NodeDataPtr HdArnoldNodeGraph::GetNode(const SdfPath& path, c
return ret;
}

AtNode *HdArnoldNodeGraph::GetMaterialxShader(const AtString &nodeType, const AtString &nodeName)
AtNode *HdArnoldNodeGraph::GetMaterialxShader(const AtString &nodeType, const AtString &nodeName, AtParamValueMap *params)
{
// Disable materialx support until it's included in the USD libs
// that are shipped with Arnold
Expand All @@ -774,7 +789,11 @@ AtNode *HdArnoldNodeGraph::GetMaterialxShader(const AtString &nodeType, const At
AtNode *node = AiNode(_renderDelegate->GetUniverse(), str::osl, nodeName);
// Get the OSL description of this mtlx shader. Its attributes will be prefixed with
// "param_shader_"
#if ARNOLD_VERSION_NUM > 70104
AtString oslCode = AiMaterialxGetOslShaderCode(nodeType.c_str(), "shader", params);
#else
AtString oslCode = AiMaterialxGetOslShaderCode(nodeType.c_str(), "shader");
#endif
// Set the OSL code. This will create a new AtNodeEntry with parameters
// based on the osl code
AiNodeSetStr(node, str::code, oslCode);
Expand Down
8 changes: 5 additions & 3 deletions render_delegate/node_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class HdArnoldNodeGraph : public HdMaterial {
};
using NodeDataPtr = std::shared_ptr<NodeData>;


using ConnectedInputs = std::unordered_map<SdfPath, TfTokenVector, TfHash>;
/// Utility struct to store the Arnold shader entries.
struct ArnoldNodeGraph {
/// Default constructor.
Expand Down Expand Up @@ -225,7 +227,7 @@ class HdArnoldNodeGraph : public HdMaterial {
/// @param node Const Reference to the Hydra Material Node.
/// @return Pointer to the Arnold Node.
HDARNOLD_API
AtNode* ReadMaterialNode(const HdMaterialNode& node);
AtNode* ReadMaterialNode(const HdMaterialNode& node, const ConnectedInputs &);

/// Looks up a shader in the internal Arnold node storage.
///
Expand Down Expand Up @@ -253,7 +255,7 @@ class HdArnoldNodeGraph : public HdMaterial {
/// @param nodeType Type of the node.
/// @return Pointer to the node, nullptr if there was an error.
HDARNOLD_API
NodeDataPtr GetNode(const SdfPath& path, const AtString& nodeType);
NodeDataPtr GetNode(const SdfPath& path, const AtString& nodeType, const ConnectedInputs &con);

/// Clears all nodes that are not used during sync.
///
Expand All @@ -270,7 +272,7 @@ class HdArnoldNodeGraph : public HdMaterial {

// Get an arnold osl node representing a materialx shader
HDARNOLD_API
AtNode *GetMaterialxShader(const AtString &nodeType, const AtString &nodeName);
AtNode *GetMaterialxShader(const AtString &nodeType, const AtString &nodeName, AtParamValueMap *params);

/// Storage for nodes created by HdArnoldNodeGraph.
std::unordered_map<SdfPath, std::shared_ptr<NodeData>, SdfPath::Hash> _nodes;
Expand Down
7 changes: 7 additions & 0 deletions testsuite/test_1333/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MaterialX texture offset

Fixes #1333

author: [email protected]

PARAMS: {'scene':'test.usda'}
145 changes: 145 additions & 0 deletions testsuite/test_1333/data/test.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#usda 1.0
(
defaultPrim = "pPlane1"
metersPerUnit = 0.01
upAxis = "Y"
)

def "Root"
{
def "Cameras"
{
def Camera "camera"
{
float4[] clippingPlanes = []
float4[] clippingPlanes.timeSamples = {
1: [],
}
float2 clippingRange = (0.00001, 10000)
float2 clippingRange.timeSamples = {
1: (0.00001, 10000),
}
float focalLength = 18.147562
float focalLength.timeSamples = {
1: 49.999996,
}
float focusDistance = 5.668885
float focusDistance.timeSamples = {
1: 4.8712945,
}
float fStop = 0
float fStop.timeSamples = {
1: 0,
}
float horizontalAperture = 20.955
float horizontalAperture.timeSamples = {
1: 20.955,
}
float horizontalApertureOffset = 0
float horizontalApertureOffset.timeSamples = {
1: 0,
}
token projection = "perspective"
token projection.timeSamples = {
1: "perspective",
}
float verticalAperture = 11.655744
float verticalAperture.timeSamples = {
1: 11.655744,
}
float verticalApertureOffset = 0
float verticalApertureOffset.timeSamples = {
1: 0,
}
matrix4d xformOp:transform = ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 5.668885231018066, 1) )
matrix4d xformOp:transform.timeSamples = {
1: ( (0.999847695156391, -3.295974604356091e-17, 0.017452406437298337, 0), (0.01744177490284497, 0.03489949670251158, -0.999238614955482, 0), (-0.0006090802009093522, 0.9993908270190954, 0.03489418134012427, 0), (-0.00296700903170605, 4.8683270374532555, 0.16997983358980104, 1) ),
}
uniform token[] xformOpOrder = ["xformOp:transform"]
}
}

def Scope "mtl"
{
def Material "standard_surface1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
token outputs:mtlx:surface.connect = </Root/mtl/standard_surface1/standard_surface1.outputs:out>
uniform float2 ui:nodegraph:node:pos = (0.055555556, 0.055555556)

def Shader "standard_surface1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_standard_surface_surfaceshader"
color3f inputs:base_color.connect = </Root/mtl/standard_surface1/image1.outputs:out>
token outputs:out
uniform float2 ui:nodegraph:node:pos = (5.138889, 0.18888889)
}

def Shader "image1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_image_color3"
asset inputs:file = @uv.jpg@
float2 inputs:texcoord.connect = </Root/mtl/standard_surface1/add1.outputs:out>
color3f outputs:out
uniform float2 ui:nodegraph:node:pos = (3.4444444, 0.5888889)
}

def Shader "texcoord1" (
active = true
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_texcoord_vector2"
float2 outputs:out
uniform float2 ui:nodegraph:node:pos = (0.055555556, 1.7944444)
}

def Shader "add1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_add_vector2"
float2 inputs:in1.connect = </Root/mtl/standard_surface1/texcoord1.outputs:out>
float2 inputs:in2 = (0.25, 0)
float2 outputs:out
uniform float2 ui:nodegraph:node:pos = (1.75, 1.65)
}
}
}

def Mesh "mesh" (
prepend apiSchemas = ["MaterialBindingAPI"]
kind = "component"
)
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, 0, -0.5), (0.5, 0, 0.5)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [0, 1, 12, 11, 1, 2, 13, 12, 2, 3, 14, 13, 3, 4, 15, 14, 4, 5, 16, 15, 5, 6, 17, 16, 6, 7, 18, 17, 7, 8, 19, 18, 8, 9, 20, 19, 9, 10, 21, 20, 11, 12, 23, 22, 12, 13, 24, 23, 13, 14, 25, 24, 14, 15, 26, 25, 15, 16, 27, 26, 16, 17, 28, 27, 17, 18, 29, 28, 18, 19, 30, 29, 19, 20, 31, 30, 20, 21, 32, 31, 22, 23, 34, 33, 23, 24, 35, 34, 24, 25, 36, 35, 25, 26, 37, 36, 26, 27, 38, 37, 27, 28, 39, 38, 28, 29, 40, 39, 29, 30, 41, 40, 30, 31, 42, 41, 31, 32, 43, 42, 33, 34, 45, 44, 34, 35, 46, 45, 35, 36, 47, 46, 36, 37, 48, 47, 37, 38, 49, 48, 38, 39, 50, 49, 39, 40, 51, 50, 40, 41, 52, 51, 41, 42, 53, 52, 42, 43, 54, 53, 44, 45, 56, 55, 45, 46, 57, 56, 46, 47, 58, 57, 47, 48, 59, 58, 48, 49, 60, 59, 49, 50, 61, 60, 50, 51, 62, 61, 51, 52, 63, 62, 52, 53, 64, 63, 53, 54, 65, 64, 55, 56, 67, 66, 56, 57, 68, 67, 57, 58, 69, 68, 58, 59, 70, 69, 59, 60, 71, 70, 60, 61, 72, 71, 61, 62, 73, 72, 62, 63, 74, 73, 63, 64, 75, 74, 64, 65, 76, 75, 66, 67, 78, 77, 67, 68, 79, 78, 68, 69, 80, 79, 69, 70, 81, 80, 70, 71, 82, 81, 71, 72, 83, 82, 72, 73, 84, 83, 73, 74, 85, 84, 74, 75, 86, 85, 75, 76, 87, 86, 77, 78, 89, 88, 78, 79, 90, 89, 79, 80, 91, 90, 80, 81, 92, 91, 81, 82, 93, 92, 82, 83, 94, 93, 83, 84, 95, 94, 84, 85, 96, 95, 85, 86, 97, 96, 86, 87, 98, 97, 88, 89, 100, 99, 89, 90, 101, 100, 90, 91, 102, 101, 91, 92, 103, 102, 92, 93, 104, 103, 93, 94, 105, 104, 94, 95, 106, 105, 95, 96, 107, 106, 96, 97, 108, 107, 97, 98, 109, 108, 99, 100, 111, 110, 100, 101, 112, 111, 101, 102, 113, 112, 102, 103, 114, 113, 103, 104, 115, 114, 104, 105, 116, 115, 105, 106, 117, 116, 106, 107, 118, 117, 107, 108, 119, 118, 108, 109, 120, 119]
rel material:binding = </Root/mtl/standard_surface1>
point3f[] points = [(-0.5, 0, 0.5), (-0.4, 0, 0.5), (-0.3, 0, 0.5), (-0.19999999, 0, 0.5), (-0.099999994, 0, 0.5), (0, 0, 0.5), (0.100000024, 0, 0.5), (0.19999999, 0, 0.5), (0.3, 0, 0.5), (0.40000004, 0, 0.5), (0.5, 0, 0.5), (-0.5, 0, 0.4), (-0.4, 0, 0.4), (-0.3, 0, 0.4), (-0.19999999, 0, 0.4), (-0.099999994, 0, 0.4), (0, 0, 0.4), (0.100000024, 0, 0.4), (0.19999999, 0, 0.4), (0.3, 0, 0.4), (0.40000004, 0, 0.4), (0.5, 0, 0.4), (-0.5, 0, 0.3), (-0.4, 0, 0.3), (-0.3, 0, 0.3), (-0.19999999, 0, 0.3), (-0.099999994, 0, 0.3), (0, 0, 0.3), (0.100000024, 0, 0.3), (0.19999999, 0, 0.3), (0.3, 0, 0.3), (0.40000004, 0, 0.3), (0.5, 0, 0.3), (-0.5, 0, 0.19999999), (-0.4, 0, 0.19999999), (-0.3, 0, 0.19999999), (-0.19999999, 0, 0.19999999), (-0.099999994, 0, 0.19999999), (0, 0, 0.19999999), (0.100000024, 0, 0.19999999), (0.19999999, 0, 0.19999999), (0.3, 0, 0.19999999), (0.40000004, 0, 0.19999999), (0.5, 0, 0.19999999), (-0.5, 0, 0.099999994), (-0.4, 0, 0.099999994), (-0.3, 0, 0.099999994), (-0.19999999, 0, 0.099999994), (-0.099999994, 0, 0.099999994), (0, 0, 0.099999994), (0.100000024, 0, 0.099999994), (0.19999999, 0, 0.099999994), (0.3, 0, 0.099999994), (0.40000004, 0, 0.099999994), (0.5, 0, 0.099999994), (-0.5, 0, 0), (-0.4, 0, 0), (-0.3, 0, 0), (-0.19999999, 0, 0), (-0.099999994, 0, 0), (0, 0, 0), (0.100000024, 0, 0), (0.19999999, 0, 0), (0.3, 0, 0), (0.40000004, 0, 0), (0.5, 0, 0), (-0.5, 0, -0.100000024), (-0.4, 0, -0.100000024), (-0.3, 0, -0.100000024), (-0.19999999, 0, -0.100000024), (-0.099999994, 0, -0.100000024), (0, 0, -0.100000024), (0.100000024, 0, -0.100000024), (0.19999999, 0, -0.100000024), (0.3, 0, -0.100000024), (0.40000004, 0, -0.100000024), (0.5, 0, -0.100000024), (-0.5, 0, -0.19999999), (-0.4, 0, -0.19999999), (-0.3, 0, -0.19999999), (-0.19999999, 0, -0.19999999), (-0.099999994, 0, -0.19999999), (0, 0, -0.19999999), (0.100000024, 0, -0.19999999), (0.19999999, 0, -0.19999999), (0.3, 0, -0.19999999), (0.40000004, 0, -0.19999999), (0.5, 0, -0.19999999), (-0.5, 0, -0.3), (-0.4, 0, -0.3), (-0.3, 0, -0.3), (-0.19999999, 0, -0.3), (-0.099999994, 0, -0.3), (0, 0, -0.3), (0.100000024, 0, -0.3), (0.19999999, 0, -0.3), (0.3, 0, -0.3), (0.40000004, 0, -0.3), (0.5, 0, -0.3), (-0.5, 0, -0.40000004), (-0.4, 0, -0.40000004), (-0.3, 0, -0.40000004), (-0.19999999, 0, -0.40000004), (-0.099999994, 0, -0.40000004), (0, 0, -0.40000004), (0.100000024, 0, -0.40000004), (0.19999999, 0, -0.40000004), (0.3, 0, -0.40000004), (0.40000004, 0, -0.40000004), (0.5, 0, -0.40000004), (-0.5, 0, -0.5), (-0.4, 0, -0.5), (-0.3, 0, -0.5), (-0.19999999, 0, -0.5), (-0.099999994, 0, -0.5), (0, 0, -0.5), (0.100000024, 0, -0.5), (0.19999999, 0, -0.5), (0.3, 0, -0.5), (0.40000004, 0, -0.5), (0.5, 0, -0.5)]
color3f[] primvars:displayColor = [(0.6666666, 0.064697616, 0.064697616)]
texCoord2f[] primvars:st = [(0, 0), (0.1, 0), (0.2, 0), (0.3, 0), (0.4, 0), (0.5, 0), (0.6, 0), (0.7, 0), (0.8, 0), (0.90000004, 0), (1, 0), (0, 0.1), (0.1, 0.1), (0.2, 0.1), (0.3, 0.1), (0.4, 0.1), (0.5, 0.1), (0.6, 0.1), (0.7, 0.1), (0.8, 0.1), (0.90000004, 0.1), (1, 0.1), (0, 0.2), (0.1, 0.2), (0.2, 0.2), (0.3, 0.2), (0.4, 0.2), (0.5, 0.2), (0.6, 0.2), (0.7, 0.2), (0.8, 0.2), (0.90000004, 0.2), (1, 0.2), (0, 0.3), (0.1, 0.3), (0.2, 0.3), (0.3, 0.3), (0.4, 0.3), (0.5, 0.3), (0.6, 0.3), (0.7, 0.3), (0.8, 0.3), (0.90000004, 0.3), (1, 0.3), (0, 0.4), (0.1, 0.4), (0.2, 0.4), (0.3, 0.4), (0.4, 0.4), (0.5, 0.4), (0.6, 0.4), (0.7, 0.4), (0.8, 0.4), (0.90000004, 0.4), (1, 0.4), (0, 0.5), (0.1, 0.5), (0.2, 0.5), (0.3, 0.5), (0.4, 0.5), (0.5, 0.5), (0.6, 0.5), (0.7, 0.5), (0.8, 0.5), (0.90000004, 0.5), (1, 0.5), (0, 0.6), (0.1, 0.6), (0.2, 0.6), (0.3, 0.6), (0.4, 0.6), (0.5, 0.6), (0.6, 0.6), (0.7, 0.6), (0.8, 0.6), (0.90000004, 0.6), (1, 0.6), (0, 0.7), (0.1, 0.7), (0.2, 0.7), (0.3, 0.7), (0.4, 0.7), (0.5, 0.7), (0.6, 0.7), (0.7, 0.7), (0.8, 0.7), (0.90000004, 0.7), (1, 0.7), (0, 0.8), (0.1, 0.8), (0.2, 0.8), (0.3, 0.8), (0.4, 0.8), (0.5, 0.8), (0.6, 0.8), (0.7, 0.8), (0.8, 0.8), (0.90000004, 0.8), (1, 0.8), (0, 0.90000004), (0.1, 0.90000004), (0.2, 0.90000004), (0.3, 0.90000004), (0.4, 0.90000004), (0.5, 0.90000004), (0.6, 0.90000004), (0.7, 0.90000004), (0.8, 0.90000004), (0.90000004, 0.90000004), (1, 0.90000004), (0, 1), (0.1, 1), (0.2, 1), (0.3, 1), (0.4, 1), (0.5, 1), (0.6, 1), (0.7, 1), (0.8, 1), (0.90000004, 1), (1, 1)] (
customData = {
dictionary Maya = {
token name = "map1"
}
}
interpolation = "faceVarying"
)
int[] primvars:st:indices = [0, 1, 12, 11, 1, 2, 13, 12, 2, 3, 14, 13, 3, 4, 15, 14, 4, 5, 16, 15, 5, 6, 17, 16, 6, 7, 18, 17, 7, 8, 19, 18, 8, 9, 20, 19, 9, 10, 21, 20, 11, 12, 23, 22, 12, 13, 24, 23, 13, 14, 25, 24, 14, 15, 26, 25, 15, 16, 27, 26, 16, 17, 28, 27, 17, 18, 29, 28, 18, 19, 30, 29, 19, 20, 31, 30, 20, 21, 32, 31, 22, 23, 34, 33, 23, 24, 35, 34, 24, 25, 36, 35, 25, 26, 37, 36, 26, 27, 38, 37, 27, 28, 39, 38, 28, 29, 40, 39, 29, 30, 41, 40, 30, 31, 42, 41, 31, 32, 43, 42, 33, 34, 45, 44, 34, 35, 46, 45, 35, 36, 47, 46, 36, 37, 48, 47, 37, 38, 49, 48, 38, 39, 50, 49, 39, 40, 51, 50, 40, 41, 52, 51, 41, 42, 53, 52, 42, 43, 54, 53, 44, 45, 56, 55, 45, 46, 57, 56, 46, 47, 58, 57, 47, 48, 59, 58, 48, 49, 60, 59, 49, 50, 61, 60, 50, 51, 62, 61, 51, 52, 63, 62, 52, 53, 64, 63, 53, 54, 65, 64, 55, 56, 67, 66, 56, 57, 68, 67, 57, 58, 69, 68, 58, 59, 70, 69, 59, 60, 71, 70, 60, 61, 72, 71, 61, 62, 73, 72, 62, 63, 74, 73, 63, 64, 75, 74, 64, 65, 76, 75, 66, 67, 78, 77, 67, 68, 79, 78, 68, 69, 80, 79, 69, 70, 81, 80, 70, 71, 82, 81, 71, 72, 83, 82, 72, 73, 84, 83, 73, 74, 85, 84, 74, 75, 86, 85, 75, 76, 87, 86, 77, 78, 89, 88, 78, 79, 90, 89, 79, 80, 91, 90, 80, 81, 92, 91, 81, 82, 93, 92, 82, 83, 94, 93, 83, 84, 95, 94, 84, 85, 96, 95, 85, 86, 97, 96, 86, 87, 98, 97, 88, 89, 100, 99, 89, 90, 101, 100, 90, 91, 102, 101, 91, 92, 103, 102, 92, 93, 104, 103, 93, 94, 105, 104, 94, 95, 106, 105, 95, 96, 107, 106, 96, 97, 108, 107, 97, 98, 109, 108, 99, 100, 111, 110, 100, 101, 112, 111, 101, 102, 113, 112, 102, 103, 114, 113, 103, 104, 115, 114, 104, 105, 116, 115, 105, 106, 117, 116, 106, 107, 118, 117, 107, 108, 119, 118, 108, 109, 120, 119]
double3 xformOp:translate = (0, 0, 0)
uniform token[] xformOpOrder = ["xformOp:translate"]
}

def DomeLight "Light"
{
asset inputs:texture:file = @@
}
}

Binary file added testsuite/test_1333/data/uv.jpg
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 testsuite/test_1333/ref/reference.tif
Binary file not shown.
16 changes: 15 additions & 1 deletion translator/reader/read_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,22 @@ void UsdArnoldReadShader::Read(const UsdPrim &prim, UsdArnoldReaderContext &cont

// Get the OSL description of this mtlx shader. Its attributes will be prefixed with
// "param_shader_"
UsdAttributeVector attributes = prim.GetAttributes();

#if ARNOLD_VERSION_NUM > 70104
AtParamValueMap * params = AiParamValueMap();
for (const auto &attribute : attributes) {
if(attribute.HasAuthoredConnections()) {
// Only the key is used, so we set an empty string for the value
AiParamValueMapSetStr(params, AtString(attribute.GetBaseName().GetString().c_str()), AtString(""));
}
}
AtString oslCode = AiMaterialxGetOslShaderCode(shaderId.c_str(), "shader", params);
AiParamValueMapDestroy(params);
params = nullptr;
#else
AtString oslCode = AiMaterialxGetOslShaderCode(shaderId.c_str(), "shader");
#endif
// Set the OSL code. This will create a new AtNodeEntry with parameters
// based on the osl code
AiNodeSetStr(node, str::code, oslCode);
Expand All @@ -112,7 +127,6 @@ void UsdArnoldReadShader::Read(const UsdPrim &prim, UsdArnoldReaderContext &cont
AiNodeSetStr(node, str::node_def, AtString(shaderId.c_str()));

// Loop over the USD attributes of the shader
UsdAttributeVector attributes = prim.GetAttributes();
for (const auto &attribute : attributes) {
std::string attrName = attribute.GetBaseName().GetString();
// only consider input attributes
Expand Down

0 comments on commit bcd25cf

Please sign in to comment.