Skip to content

Commit 9ebe5f1

Browse files
authored
Fix ND_UsdTransform2D implementation (#2924)
Addresses #2901 Reversed the direction of the transformations applied - aligning the MaterialX implementation with the USD implementation.
1 parent 0be209e commit 9ebe5f1

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

libraries/bxdf/usd_preview_surface.mtlx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,14 +430,28 @@
430430
</nodegraph>
431431

432432
<!-- Node: UsdTransform2d -->
433+
<!-- Note : The UsdTransform2d node transforms texture coordinates, not the
434+
textures themselves, so to get the effect of moving, resizing, or
435+
rotating an image being applied to a surface, one must apply the inverse
436+
transformation of how you expect the image to move. -->
433437
<nodegraph name="IMP_UsdTransform2d" nodedef="ND_UsdTransform2d">
434-
<place2d name="placement" type="vector2">
435-
<input name="texcoord" type="vector2" interfacename="in" />
436-
<input name="scale" type="vector2" interfacename="scale" />
437-
<input name="rotate" type="float" interfacename="rotation" />
438-
<input name="offset" type="vector2" interfacename="translation" />
439-
</place2d>
440-
<output name="out" type="vector2" nodename="placement" />
438+
<multiply name="N_applyscale" type="vector2">
439+
<input name="in1" type="vector2" interfacename="in" />
440+
<input name="in2" type="vector2" interfacename="scale" />
441+
</multiply>
442+
<multiply name="N_invrot" type="float">
443+
<input name="in1" type="float" value="-1" />
444+
<input name="in2" type="float" interfacename="rotation" />
445+
</multiply>
446+
<rotate2d name="N_applyrot" type="vector2">
447+
<input name="in" type="vector2" nodename="N_applyscale" />
448+
<input name="amount" type="float" nodename="N_invrot" />
449+
</rotate2d>
450+
<add name="N_applyoffset" type="vector2">
451+
<input name="in1" type="vector2" nodename="N_applyrot" />
452+
<input name="in2" type="vector2" interfacename="translation" />
453+
</add>
454+
<output name="out" type="vector2" nodename="N_applyoffset" />
441455
</nodegraph>
442456

443457
</materialx>

0 commit comments

Comments
 (0)