Autodesk / maya-usd

A common USD (Universal Scene Description) plugin for Autodesk Maya
758 stars 202 forks source link

[MAYA-114567] "uniform" opacity primVar causes geometry disappear #1687

Closed csyshing closed 2 years ago

csyshing commented 2 years ago

Describe the bug Hi,

We have a production asset that some parts of the geometries disappear, it turns out that it was causing by "uniform" interpolation opacity which mayaUsdPlugin doesn't seem to handle correctly.

Due to IP issue I am not able to provide a repro that you can see it visually, but here is a super simple repro USD file (basically a plane with "uniform" opacity):

#usda 1.0
(
    defaultPrim = "pPlane1"
)
def Mesh "pPlane1"
{
    float3[] extent = [(-0.5, -1.110223e-16, -0.5), (0.5, 1.110223e-16, 0.5)]
    int[] faceVertexCounts = [4]
    int[] faceVertexIndices = [0, 1, 3, 2]
    point3f[] points = [(-0.5, 0, 0.5), (0.5, 0, 0.5), (-0.5, 0, -0.5), (0.5, 0, -0.5)]
    float2[] primvars:st = [(0, 0), (1, 0), (0, 1), (1, 1)] (
        interpolation = "vertex"
    )
    float[] primvars:displayOpacity = [1] (
        interpolation = "uniform"
    )
}

I tried to put some debug output around here: https://github.com/Autodesk/maya-usd/blob/dev/lib/mayaUsd/render/vp2RenderDelegate/mesh.cpp#L1743-L1745

....
line 1743:    int x = _meshSharedData->_renderingToSceneFaceVtxIds[triangle[0]];    // (x, y, z) == (0, 1, 3)
line 1744:    int y = _meshSharedData->_renderingToSceneFaceVtxIds[triangle[1]];    // "y" index out of range
line 1745:    int z = _meshSharedData->_renderingToSceneFaceVtxIds[triangle[2]];    // "z" index out of range
line 1746:    if (alphaArray[x] < 0.999f || alphaArray[y] < 0.999f                  // Accessing values from "y" /"z" out of the alphaArray
line 1747:       || alphaArray[z] < 0.999f) {                                       // alphaArray[x, y, z] == (1, 0, 0)
line 1748:           renderItemData._transparent = true;                            // Transparent unexpectedly becomes "true"
line 1749:           break;
line 1750:    }
....

The example USD above, alphaArray has just 1 element which matches the raw primVar declared in USD, our production asset is more complicated but essentially the same as above.

If you need more info, please do let me know! Thanks, Zhicheng

Steps to reproduce Steps to reproduce the behavior:

  1. Launch Maya and load mayaUsdPlugin
  2. Create proxy shape with the example USD file above
  3. Observe the debug output message

Expected behavior A clear and concise description of what you expected to happen.

Attachments If applicable, add screenshots, sample files, etc to help explain your problem.

Specs (if applicable):

wtelford commented 2 years ago

hey @santosd can you log this internally?

santosd commented 2 years ago

Logged internally as MAYA-114567

santosd commented 2 years ago

Hello @csyshing, I wanted to let you know that we have fixed this issue on our end. Feel free to test and let us know if you come across any other issues. I am going to go ahead and close this ticket out for the time being.