maya-usd icon indicating copy to clipboard operation
maya-usd copied to clipboard

Exporting displayColor set results in nan values

Open JakobJK opened this issue 6 months ago • 1 comments

Describe the bug When exporting geometry containg a color set that has negative values, the resulting color value becomes nan.

Steps to reproduce

  1. Create a piece of geometry (a cube in this case) with a USD preview shader. Set the values to a negative value. (ex: (1.2, -0.2, 4))
  2. Export selected as USD. Make sure you are exporting color sets and displayColor
  3. Here is the result:
#usda 1.0
(
    defaultPrim = "pCube1"
    metersPerUnit = 0.01
    upAxis = "Y"
)

def Mesh "pCube1" (
    prepend apiSchemas = ["MaterialBindingAPI"]
    kind = "component"
)
{
    uniform bool doubleSided = 1
    float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
    int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
    int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
    rel material:binding = </pCube1/mtl/usdPreviewSurface2SG>
    point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
    color3f[] primvars:displayColor = [(1.4934778, nan, 21.112127)] (
        customData = {
            dictionary Maya = {
                bool generated = 1
            }
        }
    )

    def Scope "mtl"
    {
        def Material "usdPreviewSurface2SG"
        {
            token outputs:surface.connect = </pCube1/mtl/usdPreviewSurface2SG/usdPreviewSurface2.outputs:surface>

            def Shader "usdPreviewSurface2"
            {
                uniform token info:id = "UsdPreviewSurface"
                color3f inputs:diffuseColor = (1.2, -0.2, 4)
                token outputs:displacement
                token outputs:surface
            }
        }
    }
}

Expected behavior I would have expected the value to be the result of the diffuseColor having the ASECcg transformation applied.

sRGB -> ASECcg: sRGB value: (1.2, -0.2, 4) Expected ASECcg value: (2.124096632003784, 0.43282783031463623, 22.048145294189453)

Why is the result (1.4934778, nan, 21.112127)? Where did the nan come from?

I'm by no means an expert at color transformations, so I may have fundamentally misunderstood something, but I'm happy to learn. Thanks!

JakobJK avatar Oct 16 '25 14:10 JakobJK

Thanks for reporting. We'll investigate.

wallworm avatar Oct 16 '25 16:10 wallworm