Skip to content

Commit 4a24595

Browse files
committed
Don't flatten USDs; merging meshes shouldn't be the responsibility of the importor. Breakout references and variants into separate phases
Signed-off-by: AMZN-Gene <[email protected]>
1 parent e77a84c commit 4a24595

File tree

1 file changed

+83
-29
lines changed

1 file changed

+83
-29
lines changed

rfcs/RFC Feature - USD in the Scene Pipeline.md

Lines changed: 83 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,34 @@ Build support for USD into the scene pipeline.
183183
184184
Do this in three phases:
185185
186-
1. Upgrade O3DE to use Assimp's latest implementation
187-
1. Input: single USD geometry files that don't use layers or references
188-
2. Output: azmodel containing the USDs geometry 
189-
2. Contribute back to Assimp and update scene builder to load USD files with references. Stages are flattened by adding in reference geometry. O3DE then processes USD like FBX and other scene file formats.
190-
1. Input: USD files which contains a hierarchy of references to other geometry inside of other USD files 
191-
2. Output: Flattened azmodel containing the geometry from the multiple USD files inside one azmodel file
192-
3. Contribute back to Assimp giving API option to flatten stages or keep reference geom separate. Update O3DE to create a procedural prefab that mimics the relationship graph of USD files by matching models and transforms. This could be expanded later to allow O3DE developers to translate USD properties into O3DE component properties as well as add advanced shaders/materials.
193-
1. Input: USD files which contains a hierarchy of references to other geometry inside of other USD files
194-
2. Output: Procedural prefabs generated per USD. Root prefab preserves the hierarchy of the original USD.
186+
1. Single USD
187+
1. Upgrade O3DE to use Assimp's latest implementation
188+
2. Input: single USD geometry files that don't use layers or references
189+
3. Output: azmodel containing the USDs geometry 
190+
2. USD with References
191+
1. Update Assimp scene tree with tags for referenced USD files
192+
2. Update O3DE scene builder to load USD files and look for reference tags.
193+
3. Update O3DE to create a procedural prefab that mimics the relationship graph of USD files by matching models and transforms
194+
4. Input: USD files which contains a hierarchy of references to other geometry inside of other USD files 
195+
5. Output: Procedural prefabs generated for the root USD as well as referenced USDs. Root prefab preserves the hierarchy of the original USD.
196+
3. USD with Variants
197+
1. Updated Assimp scene tree with tags for variants within a USD
198+
2. Update O3DE scene builder to load USD files and look for variants
199+
3. Input: USD file which contains X variants
200+
4. Output:
201+
1. X meshes and X prefabs generated for each variant
202+
2. Prefabs which references a variant in its hierarchy will nest 1 of the prefab variants
195203
196204
### Why these three phases?
197205
198206
* Phase 1 is extremely fast.
199-
* The work for phase 2 is used in phase 3, so there won't be much wasted effort here.
200207
* Once phase 2 is completed, there's great benefits to using USD: content creators can start splitting up content on their end.
201-
* Benefits of phase:
208+
* Benefits of phase 2:
202209
* Performance - asset processing time, and hard drive space used by product assets: We won't need to re-create product assets, such as models, that are referenced by multiple other USD files.
203210
* Workflow - additional procedural prefabs will be available for content creators to use in the Editor.
211+
* Phase 3 and beyond nice-to-have.
212+
* Variants are advanced so makes sense to break them out into a later phase.
213+
* Avoid variant explosion by only selecting 1 of many variants when generating procedural prefabs
204214
205215
### Simple Example
206216
![image](https://github.com/user-attachments/assets/2eaf9c33-0fb0-403a-a954-837695c91c6f)
@@ -252,9 +262,9 @@ Warning | The builder (Scene Builder) has not indicated it handled outputting pr
252262
253263
Phase 2 enables referencing...
254264
255-
### Phase 2 - Update Assimp to support flattened USD with references
265+
### Phase 2 - Update Assimp to support USD with references
256266
257-
Update Assimp to read USDs, composite all sub-layers and references and flatten all the meshes into one Assimp scene. O3DE will treat the root USD as one big mesh.
267+
Update Assimp to read USDs, composite all sub-layers and tag references in Assimp scene. O3DE will parse the Assimp tree to find references and spin off procedural prefabs.
258268
259269
#### The Current Setup
260270
@@ -297,8 +307,14 @@ def Xform "Xform"
297307
1. See USD documentation on Asset Resolution:
298308
1. [https://graphics.pixar.com/usd/release/glossary.html#usdglossary-assetresolution](https://graphics.pixar.com/usd/release/glossary.html#usdglossary-assetresolution)
299309
2. [https://graphics.pixar.com/usd/release/api/ar\_page\_front.html](https://graphics.pixar.com/usd/release/api/ar_page_front.html)
300-
2. Update Assimp to generate an Assimp scene by flattening and resolving the O3DE scene
301-
1. Today a USD loaded via Assimp returns a scene, but if that scene references other USD files, the scene won't contain the geometry of the references. Update Assimp to recursively find references and mark them as a file dependency.
310+
2. Update Assimp to generate an Assimp scene containing a way to recognize references
311+
1. Today a USD loaded via Assimp returns a scene, but if that scene references other USD files, the scene won't contain the geometry of the references. Update Assimp to recursively find references and tag them as a reference (include necessary data such as file path, and reference name)
312+
1. Assimp outputs the scene graph like it currently does, but when it hits a reference, it annotates that node in the scene graph with a property that describes the reference.
313+
1. Assimp::Scene root "kitchen"
314+
1. child 01
315+
1. Name: "spoon 01"
316+
2. Transform: <translation>, <rotation>, <scale>
317+
3. Reference: "c:/project/spoon.usd"
302318
303319
TinyUSDZ, the 3rd Party USD library used by Assimp, has methods for discovering references geometry.
304320
@@ -317,25 +333,46 @@ def Xform "Xform"
317333
std::map<std::string, const tinyusdz::GeomMesh*> meshmap;
318334
tinyusdz::tydra::ListPrims(stage, meshmap);
319335
```
320-
Note: USD can reference other USDs or geometry from other file types (example: obj). As long as the file type is supported by Assimp, we can load this geom and add it to the final flattened Assimp scene.
336+
Note: USD can reference other USDs or geometry from other file types (example: obj). As long as the file type is supported by Assimp, Assimp can tag it, and O3DE can load the geom and add it to the procedural prefab.
321337
322338
323339
More Information: [Accessing Reference File Geom · Issue #186 · lighttransport/tinyusdz (github.com)](https://github.com/lighttransport/tinyusdz/issues/186)
324340
325-
3. From here, the current O3DE pipeline would take over, we would consume this flattened scene.
341+
3. From here, the current O3DE pipeline would take over, we would consume this scene.
326342
1. ![image](https://github.com/user-attachments/assets/e4aac22e-0ec1-463a-96a6-a2b3fbfe7ec7)
343+
2. Update Create Jobs in the scene builder to output job dependencies on referenced USD files.
344+
3. [See FAQ for why we need both source and job dependencies](#USDintheScenePipeline-Whydoweneedbothsourcedependenciesandjobdependenciesforreferences?).
345+
4. Job dependencies will be needed at this point because product assets from one USD file (prefabs, models, etc) will be referenced by other USD files to mimic the USD relationship graph.
346+
5. Update the scene builder to generate USD based procedural prefabs.
347+
1. We will need to define what these look like. [We may need additional features from procedural prefabs to hit our end goals](https://wiki.agscollab.com/display/lmbr/USD+in+the+Scene+Pipeline#USDintheScenePipeline-WhatdoweneedfromproceduralprefabsforUSDtobefullyfunctional?).
348+
349+
### Phase 3 - Update Assimp to support USD with Variants
350+
351+
Variants are switchable references. Ideally, an O3DE component could provide a drop down in editor to quickly select from a list of variants within a variant set, but this phase simply recognizes variants in order to generate a mesh and prefab for each. Any root USD referencing a variant set will make a single variant selection.
352+
1. Update Assimp to generate an Assimp scene containing a way to recognize variant sets, via tagging
353+
1. Assimp outputs the scene graph like it currently does, but when it hits a variant, it annotates that node in the scene graph with a property.
354+
1. Assimp::Scene root "kitchen"
355+
1. child 01
356+
1. Name: "spoon 01"
357+
2. Transform: <translation>, <rotation>, <scale>
358+
3. Reference: "c:/project/spoon.usd"
359+
4. Variant: "WoodenSpoonA"
360+
2. O3DE pipeline would consume this scene
361+
1. Update scene builder to look for "variant set" and "variant" tags
362+
2. Update scene builder to generate a procedural prefab for each variant in a variant set
363+
3. Update scene builder so root USD prefabs referencing a variant set (referenced inline or another .usd file) will have a variant selected for them in their procedural prefab
364+
1. In instances where the USD calls out a variant set, but no selection, the 1st variant in the variant set list will be selected
365+
4. Do not try to combine
366+
1. A single chair.usd becomes:
367+
1. chair.procprefab
368+
2. chairback_01.procprefab -> chairback_01.atommesh
369+
...
370+
3. chaircushion_01.procprefab -> chaircushion_01.atommesh
371+
372+
Note: Variants are not always meshes, they can also just be basic overrides for transforms, material properties, etc.
373+
We should support transforms, but material properties and beyond will wait for future roadmap.
327374
328375
329-
### Phase 3 - Prefab output mimicking USD relationship graph
330-
331-
* Add a feature flag to toggle USD flattening off, so we can deliver the rest of this work iteratively.
332-
* Update Create Jobs in the scene builder to output job dependencies on referenced USD files.
333-
* [See FAQ for why we need both source and job dependencies](#USDintheScenePipeline-Whydoweneedbothsourcedependenciesandjobdependenciesforreferences?).
334-
* Job dependencies will be needed at this point because product assets from one USD file (prefabs, models, etc) will be referenced by other USD files to mimic the USD relationship graph.
335-
* Update the scene builder to generate USD based procedural prefabs.
336-
* We will need to define what these look like. [We may need additional features from procedural prefabs to hit our end goals](https://wiki.agscollab.com/display/lmbr/USD+in+the+Scene+Pipeline#USDintheScenePipeline-WhatdoweneedfromproceduralprefabsforUSDtobefullyfunctional?).
337-
* Decide if we want to either keep the feature flag for USD flattening and turn it off by default, or remove the flag and remove USD flattening support in process job.
338-
339376
Alternate Solutions
340377
===================
341378
@@ -378,7 +415,7 @@ Do we need to emit references to other USD files as job dependencies, or can the
378415
379416
If we're able to fully rely on procedural prefabs to manage the composition of USD file references, and we're able to predict the sub IDs of products from other USD files, then we may not need to emit these references as source dependencies.
380417
381-
USD has support for [abstract base objects](https://wiki.agscollab.com/display/lmbr/USD+Investigation#USDInvestigation-AbstractObjects), that function sort of as inverted overrides. Our prefab system does not have a similar concept, so we may need to output job or source dependencies to use this information to build a prefab hierarchy. We may find that we instead need to add this sort of functionality to prefabs.
418+
USD has support for abstract base objects, that function sort of as inverted overrides. Our prefab system does not have a similar concept, so we may need to output job or source dependencies to use this information to build a prefab hierarchy. We may find that we instead need to add this sort of functionality to prefabs.
382419
383420
### Example
384421
@@ -464,11 +501,28 @@ Out of Scope / Long Term Work
464501
465502
Advanced shaders and materials
466503
------------------------------
467-
468504
For our initial deliverable, we will generate basic O3DE physically based rendering materials.
469505
470506
However, the options for shaders and materials from USD files are much bigger than that. As we wrap up our first set of work to support USD, we'll want to start planning what a more fully featured material and shader pipeline from USD files could look like.
471507
508+
Extra USD Properties and O3DE Components
509+
------------------------------
510+
Allow developers to read generic scene information, and inject custom components into the procedural prefabs generated by importing USD files. O3DE would ship with built-in components.
511+
1. Update Assimp to output USD property data
512+
1. Assimp::Scene root "kitchen"
513+
1. child 01
514+
1. Name: "spoon 01"
515+
2. Transform: <translation>, <rotation>, <scale>
516+
3. Reference: "c:/project/spoon.usd"
517+
4. Variant: "WoodenSpoonA"
518+
5. NEW: Other user data/properties/overrides
519+
520+
1. O3DE scene system already supports storing generic info into each scene node
521+
522+
Editor Variant Selection Dropdown
523+
------------------------------
524+
Allow designers to select from a list of available variants from within the editor when a variant set is included in a USD
525+
472526
Convert O3DE prefabs to USD files
473527
---------------------------------
474528

0 commit comments

Comments
 (0)