Related to my prior question: https://forums.unrealengine.com/t/exporting-twinmotion-material-to-usd-material-texture-rotated-and-wrong-scale/1415988
I added the following UsdTransform2d into the material definition to rotate and scale the input PNGs.
def Shader "UsdTransform2d"
{
uniform token info:id = "UsdTransform2d"
float2 inputs:in.connect = </MI_BrickClean02/PrimvarReader.outputs:result>
float inputs:rotation = 90.0
float2 inputs:scale = (0.38, 0.38)
float2 inputs:translation = (0.0, 0.0)
float2 outputs: result
}
And I checked the result in USDView - and it behaves as expected (note that the meter cube with the native UE material is 5 bricks wide - I set the scale by trial and error):
However, the same usda (with the transform in place) is still incorrect in UE:
BTW, if I manually rotate the PNGs I can fix the orientation. But I can’t easily fix the scaling.
I can also edit the UE Material Def to rotate and scale the native material - but this doesn’t seem to impact the export process (which I guess makes sense - it seems that the export process is exporting the raw material inputs whereas the material displayed in the UE pre-processes those inputs before applying the material to the cube).
Any help greatfully received! Thanks!
BTW - my goal is to have a UE app that the user can dynamically load different material libraries in USD format. And some users may in fact source their materials from UE exports (which is why I want to be able to roundtrip UE->USD->UE), while others may source other PBR materials elsewhere (and convert them to USD).
UPDATE:
On first loading the USDA with a fresh USD Asset Cache I get the following warning messages:
Failed to find primvar used as st input for texture 'c:/usd/materials/library/materials/Brick/Textures/MI_BrickClean02_Normal.png' in material 'Material_43'. Will use UV index 0 instead
(I get the message for each of the base color, roughness and normal png - and the st input is the one that’s bound to the output from the UsdTransform2d)