Skip to content

Conversation

zphr
Copy link
Contributor

@zphr zphr commented Mar 6, 2025

Description

  • This PR solves that wrong references for instantiated materials are generated for an USDZ export.
    The old code did not reuse the right instantiated material and then generated references with material ids that were not present in the material definitions.

Screenshot from 2026-03-06 07-40-58

  • Broken export (shortened):
    def Xform "Object_171" (
      prepend references = @./geometries/Geometry_42.usd@</Geometry>
    )
    {
      ...
      rel material:binding = </Materials/Material_58>
    }
    def Xform "Object_172" (
      prepend references = @./geometries/Geometry_44.usd@</Geometry>
    )
    {
      ...
      rel material:binding = </Materials/Material_59>
    }
    def Xform "Object_174" (
      prepend references = @./geometries/Geometry_46.usd@</Geometry>
    )
    {
      ...
      rel material:binding = </Materials/Material_60>
    }
    def "Materials"
    {
    - def Material "Material_58"
      {
        ...
      }
    }
    
  • Fixed export (shortened):
    def Xform "Object_170" (
    prepend references = @./geometries/Geometry_44.usda@</Geometry>
    )
    {
    ...
    rel material:binding = </Materials/Material_56>
    }
    def Xform "Object_172" (
    prepend references = @./geometries/Geometry_46.usda@</Geometry>
    )
    {
    ...
    rel material:binding = </Materials/Material_56>
    }
    def Xform "Object_177" (
    prepend references = @./geometries/Geometry_48.usda@</Geometry>
    )
    {
    ...
    rel material:binding = </Materials/Material_56>
    }
    - def "Materials"
    {
    - def Material "Material_56"
    {
    ...
    }
    }
    

This contribution is funded by ObjectCode

@zphr zphr changed the title Reuse instantiated material for buildXform to avoid generating references to missing materials USDZ Export: Reuse instantiated material for buildXform to avoid generating references to missing materials Mar 6, 2025
@mrdoob mrdoob added this to the r175 milestone Mar 6, 2025
@mrdoob mrdoob merged commit c399a18 into mrdoob:dev Mar 6, 2025
11 checks passed
@Mugen87 Mugen87 changed the title USDZ Export: Reuse instantiated material for buildXform to avoid generating references to missing materials USDZExporter: Reuse instantiated material for buildXform(). Mar 19, 2025
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

Successfully merging this pull request may close these issues.

3 participants