Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify indices for normals, texture coordinates, and others, separately? #706

Closed
zeman-88 opened this issue Nov 26, 2018 · 2 comments

Comments

@zeman-88
Copy link

I would like to specify the indices for other attributes other than the "point" ones.

I.e.: if I have N positions, and M normals, the indices for the normals for that Mesh are different from the ones for the positions.
Hence a call to CreateFaceVertexIndicesAttr won't cut it, as that only specifies the indices as if all the attributes for a vertex follow the same indexing.

Take this Mesh as an example:

    def Mesh "geometry15"
    {
        float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
        int[] faceVertexCounts = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
        int[] faceVertexIndices = [0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 8, 11, 9, 8, 10, 11, 12, 15, 13, 12, 14, 15, 16, 19, 17, 16, 18, 19, 20, 23, 21, 20, 22, 23]
        rel material:binding = </material5>
        normal3f[] normals = [(0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8)]
        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), (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), (-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)]
        texCoord2f[] primvars:st = [(0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1)] (
            interpolation = "faceVarying"
        )
        int[] primvars:st:indices = [0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 8, 11, 9, 8, 10, 11, 12, 15, 13, 12, 14, 15, 16, 19, 17, 16, 18, 19, 20, 23, 21, 20, 22, 23]
        uniform token subdivisionScheme = "none"
    }

what if I wanted to have a different number of normals from the vertices and specify their indexing differently? I would like to achieve something like this:

    def Mesh "geometry15"
    {
        float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
        int[] faceVertexCounts = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
        int[] facePositionIndices = [0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 8, 11, 9, 8, 10, 11, 12, 15, 13, 12, 14, 15, 16, 19, 17, 16, 18, 19, 20, 23, 21, 20, 22, 23]
        // Here I am changing the numbers at random to explain the concept
        int[] faceNormalIndices = [0, 2, 1, 0, 3 10, 5, 10, 5, 4, 6, 7, 8, 11, 9, 8, 10, 11, 12, 15, 13, 12, 14, 15, 16, 19, 17, 16, 18, 19, 20, 23, 21, 20, 22, 23]
        rel material:binding = </material5>
        normal3f[] normals = [(0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (1, 0, -4.37114e-8), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-8.74228e-8, 0, -1), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (-1, 0, 1.19249e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, 1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8), (0, -1, -4.37114e-8)]
        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), (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), (-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)]
        texCoord2f[] primvars:st = [(0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (0, 0), (0, 1), (1, 0), (1, 1)] (
            interpolation = "faceVarying"
        )
        int[] primvars:st:indices = [0, 3, 1, 0, 2, 3, 4, 7, 5, 4, 6, 7, 8, 11, 9, 8, 10, 11, 12, 15, 13, 12, 14, 15, 16, 19, 17, 16, 18, 19, 20, 23, 21, 20, 22, 23]
        uniform token subdivisionScheme = "none"
    }

How can I specify different indices for different attributes of a vertex for a mesh?

@zeman-88
Copy link
Author

I can answer this for myself, as I was already doing it for the texture coordinates: create a Primvar manually and assign it its own indices manually, like it's done for texture coordinates.

@spiffmon
Copy link
Member

spiffmon commented Nov 26, 2018 via email

AdamFelt pushed a commit to autodesk-forks/USD that referenced this issue Apr 16, 2024
… have word break index. (PixarAnimationStudios#706)

### Description of Change(s)
Fix build break on Mac, and the problem that the zero line should not have word break index.
### Fixes Issue(s)
-

<!--
Please follow the Contributing and Building guidelines to run tests against your
change. Place an X in the box if tests are run and are all tests passing.
-->
- [ ] I have verified that all unit tests pass with the proposed changes
<!-- 
Place an X in the box if you have submitted a signed Contributor License Agreement.
A signed CLA must be received before pull requests can be merged.
For instructions, see: http://openusd.org/release/contributing_to_usd.html
-->
- [ ] I have submitted a signed Contributor License Agreement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants