USD Shape IO Support #101285

Open
opened 2022-09-23 02:57:47 +02:00 by Michael Kowalski · 7 comments

On the most basic level, this feature would allow importing USD shapes (capsule, cone, cube, cylinder, sphere) as Blender meshes. More advanced implementations could include options for alternate, lightweight representations of shapes in the Blender scene, e.g., exploiting instancing, custom viewport rendering that does not require importing the mesh data, etc.

@charlesfleche discussed the following suggestions re USD shape support on the pipeline-assets-io-module Blender chat channel on 22 Sep 2022.


Our main use case is to represent collision objects. For performance reasons we can feed simple collision objects to the physic component of the game engine. For example, rather that computing a collision with a complex character head that as many faces, you can define a simple sphere that is much faster to compute collision against.

But sometimes simple shapes are not enough: in this case we still want as fast as a collision computation as possible, and use a convex mesh to approximate the visual shape as much as possible. And when we really, really require high precision we'd use a mesh that can be complex and convex.

We also have the concept of collision Level Of Detail. The typical example is a fence:

  • you don't the player to walk through the fence, but for that purpose you can approximate the shape of the fence with a single parametric box
  • but you still want a bullet to go through the holes of the fence: for collision with ammunitions, you'd use a more detailed mesh

But not all DCC support parametric shapes, so for simplicity (and for now), we are still importing USD shapes as meshes in the DCCs, but on way back to USD we compute the bounding volumes of the requested shape. In practice, it looks like this:

  • In USD: UsdGeomCube MyObject_BOX with a size attribute + xform
  • In the DCC: we extract the dimension of the box from the scale component of the transform and generate a box mesh, with custom code ran at import time
  • DCC user is editing the box
  • In the DCC: the object is a _BOX, we compute the Box Bounding Volume and store the x, y, z dimensions as in the xform as scale
  • In USD: UsdGeomCube MyObject_BOX wih a size attribute + xform

It is not great because the users don't have the same representation in engine vs the DCC. In engine they'd handle Radius and Height parameters, in the DCC it's a bunch of vertices.

So the idea, for Blender, would be to leverage the geometry nodes to give the user parameters to play with (radius, height), even if the actual object in Blender is still a mesh.

Geometry Nodes presets should be enough for now. After all, you can already generate those shapes in the Geometry Nodes already. What is important would be to have control, even if purely manual at import time, on how the Shape will be presented in Blender. For example, most users will want a Box to be defined with three parameters: sizeX, sizeY, sizeZ. However, depending of the physics engine you are dealing with, sometimes boxes are represented by two vectors: bottom-left and top-right. To match the Engine representation in the DCC, we'd need to be able to replace the default Geometry node by ours, where we'd expose the bottom-left / top-right vectors to the user.

On the most basic level, this feature would allow importing USD shapes (capsule, cone, cube, cylinder, sphere) as Blender meshes. More advanced implementations could include options for alternate, lightweight representations of shapes in the Blender scene, e.g., exploiting instancing, custom viewport rendering that does not require importing the mesh data, etc. @charlesfleche discussed the following suggestions re USD shape support on the `pipeline-assets-io-module` Blender chat channel on 22 Sep 2022. --- Our main use case is to represent collision objects. For performance reasons we can feed simple collision objects to the physic component of the game engine. For example, rather that computing a collision with a complex character head that as many faces, you can define a simple sphere that is much faster to compute collision against. But sometimes simple shapes are not enough: in this case we still want as fast as a collision computation as possible, and use a convex mesh to approximate the visual shape as much as possible. And when we really, really require high precision we'd use a mesh that can be complex and convex. We also have the concept of collision Level Of Detail. The typical example is a fence: - you don't the player to walk through the fence, but for that purpose you can approximate the shape of the fence with a single parametric box - but you still want a bullet to go through the holes of the fence: for collision with ammunitions, you'd use a more detailed mesh But not all DCC support parametric shapes, so for simplicity (and for now), we are still importing USD shapes as meshes in the DCCs, but on way back to USD we compute the bounding volumes of the requested shape. In practice, it looks like this: - In USD: `UsdGeomCube` MyObject_BOX with a size attribute + xform - In the DCC: we extract the dimension of the box from the scale component of the transform and generate a box mesh, with custom code ran at import time - DCC user is editing the box - In the DCC: the object is a _BOX, we compute the Box Bounding Volume and store the x, y, z dimensions as in the xform as scale - In USD: `UsdGeomCube` MyObject_BOX wih a size attribute + xform It is not great because the users don't have the same representation in engine vs the DCC. In engine they'd handle Radius and Height parameters, in the DCC it's a bunch of vertices. So the idea, for Blender, would be to leverage the geometry nodes to give the user parameters to play with (radius, height), even if the actual object in Blender is still a mesh. `Geometry Nodes` presets should be enough for now. After all, you can already generate those shapes in the `Geometry Nodes` already. What is important would be to have control, even if purely manual at import time, on how the Shape will be presented in Blender. For example, most users will want a Box to be defined with three parameters: `sizeX, sizeY, sizeZ`. However, depending of the physics engine you are dealing with, sometimes boxes are represented by two vectors: `bottom-left` and `top-right`. To match the Engine representation in the DCC, we'd need to be able to replace the default Geometry node by ours, where we'd expose the `bottom-left` / `top-right` vectors to the user.
Author
Member
Added subscribers: @charlesfleche, @makowalski, @CharlesWardlaw, @SonnyCampbell_Unity, @dr.sybren
Author
Member

Added subscriber: @BrianSavery

Added subscriber: @BrianSavery

Added subscriber: @Zhen-Dai

Added subscriber: @Zhen-Dai
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk

Added subscriber: @GeorgiaPacific

Added subscriber: @GeorgiaPacific
Author
Member

Added subscriber: @mont29

Added subscriber: @mont29

Hey all,

I've made a patch for this internally. Currently it follows the Maya implementation, converting the UsdShape objects into mesh objects using the Adapter classes provided. At the moment it's one resolution fits all, but I could add a subdivision modifier or try to match subdivision schema on the file being imported. There is currently no round-tripping.

The Geometry Nodes idea is a good one with regards to attempting to round-trip shape changes, and that's something I could do, but how do folks want to detect that a geometry nodes network is mimicking Geometry Nodes vs not? Would export be based on network name + available attributes, and if both don't exist it gets treated like a regular mesh?

I suppose this would also require a new menu be added to the Shift+A menu for UsdShapes?

Hey all, I've made a patch for this internally. Currently it follows the Maya implementation, converting the UsdShape objects into mesh objects using the Adapter classes provided. At the moment it's one resolution fits all, but I could add a subdivision modifier or try to match subdivision schema on the file being imported. There is currently no round-tripping. The Geometry Nodes idea is a good one with regards to attempting to round-trip shape changes, and that's something I could do, but how do folks want to detect that a geometry nodes network is mimicking Geometry Nodes vs not? Would export be based on network name + available attributes, and if both don't exist it gets treated like a regular mesh? I suppose this would also require a new menu be added to the Shift+A menu for UsdShapes?
Bastien Montagne added this to the Pipeline, Assets & IO project 2023-02-09 15:39:30 +01:00
Bastien Montagne modified the project from Pipeline, Assets & IO to USD 2023-02-10 11:08:11 +01:00
Bastien Montagne added
Status
Confirmed
and removed
Status
Needs Triage
labels 2023-02-10 12:24:54 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#101285
No description provided.