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

USDZExporter: Store only unique geometry and reference it #21749

Merged
merged 1 commit into from
May 3, 2021
Merged

USDZExporter: Store only unique geometry and reference it #21749

merged 1 commit into from
May 3, 2021

Conversation

qeeqez
Copy link
Contributor

@qeeqez qeeqez commented Apr 29, 2021

Fixed #21748

Description

Now we are storing only unique geometries in different geometry.usd file.
model.usda have only references to geometries (meshes).

Also, geometry do not store material references. Xforms from model.usda now do it.
It could help us with storing of many identical objects but with different materials binded

@qeeqez qeeqez changed the title USDExporter: Store only unique geometry and reference it USDZExporter: Store only unique geometry and reference it Apr 29, 2021
@mrdoob mrdoob added this to the r129 milestone May 3, 2021
@mrdoob mrdoob merged commit 00b44e3 into mrdoob:dev May 3, 2021
@mrdoob
Copy link
Owner

mrdoob commented May 3, 2021

Excellent! Thanks!

@qeeqez qeeqez deleted the USDZ-export-use-referenced-geometry branch May 3, 2021 07:32
@mrdoob
Copy link
Owner

mrdoob commented May 3, 2021

Now we are storing only unique geometries in different geometry.usd file.

Out of curiosity, why do we need to store them in a different file?

@qeeqez
Copy link
Contributor Author

qeeqez commented May 3, 2021

Now we are storing only unique geometries in different geometry.usd file.

Out of curiosity, why do we need to store them in a different file?

If we'll add geometry to the "output" - it will be instantiated in zero point. And we will see geometry itself in zero point + instantiated objects in correct places.

We have multiple solutions:

  1. Make geometry invisible.
    But overriding this invisible state in the instance do not work thus we could not see instances ¯\_(ツ)_/¯
  2. Store geometry in the first object's instance and then reference it.
    Good solution but we'll have some problems with overriding materials and etc.
  3. Store geometry in a different file. This one is merged.
    Pixar's USD examples uses this approach in many places so I think it's a best solution.
    • Some complex example
    • Simplier example
      p.s. looks like they are storing every geometry in a separate file: we could do the same so we'll further improve memory usage during file creation. But final USDZ will be a little bit bigger as every .usd file should have a header on the top.

Note: not all of the features of USDZ format are implemented or work in AR QuickLook.
We could have some solutions working in the Xcode AR View but not in the AR Quick Look

@mrdoob
Copy link
Owner

mrdoob commented May 3, 2021

p.s. looks like they are storing every geometry in a separate file: we could do the same so we'll further improve memory usage during file creation.

Yes, I was thinking if that would be better. I found it weird when I tested this and I saw the geometry.usd file with all geometries on top of each other. Makes it hard to debug.

But final USDZ will be a little bit bigger as every .usd file should have a header on the top.

I think it'd be worth it.

@qeeqez
Copy link
Contributor Author

qeeqez commented May 3, 2021

@mrdoob
Question about file structure we want to have:

Now Proposed
model.usda
def Xform "Object_ID"
references = @./geometry.usd@</Geometry_ID>
model.usda
def Xform "Object_ID"
references = @./geometries/Geometry_ID.usd@
geometry.usd
def "Geometry_ID"
def Mesh "Geometry_ID"
geometry_ID.usd
def "Geometry"
def Mesh "Geometry"

Basically my proposal - store geometry ID in file names (similar to current textures storage). And inside the file we will only use "Geometry" word without ID.

@mrdoob
Copy link
Owner

mrdoob commented May 3, 2021

The proposed approach looks great to me 👍

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.

USDExporter: browser tab crashes during export of complex geometry
2 participants