Skip to content

[FEATURE] Decouple FEM render geometry from simulation geometry. - #3079

Closed
duburcqa wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
duburcqa:fem_render_decoupling
Closed

[FEATURE] Decouple FEM render geometry from simulation geometry.#3079
duburcqa wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
duburcqa:fem_render_decoupling

Conversation

@duburcqa

Copy link
Copy Markdown
Collaborator

Description

FEM entities now expose their morph sub-meshes as visual geoms (fem_entity.vgeoms, mirroring the rigid entity API): each FEMVisGeom pairs a render mesh carrying its own surface and UVs with the map from its vertices to the simulated vertices. The rasterizer and raytracer draw the authored input surface per visual geom and update its vertices from the simulation state through that map, while the FEM solver drops its render-only topology and UV fields. Sub-meshes are welded into a single simulation mesh before tetrahedralization, which now runs before the morph position is applied so the tetrahedralization and its on-disk cache are shared across placements of the same geometry. The normal render pass supports double-sided primitives in both offscreen and interactive viewer renders through a shared shader cache keyed on the primitive defines.

Related Issue

Supersedes #2904.

Motivation and Context

Multi-material assets lost their appearance when simulated as FEM entities: rendering used the tetrahedral boundary with a single entity-wide surface and zero-padded UVs. Decoupling render geometry from simulation geometry preserves the authored look (per-sub-mesh materials, textures, UVs) and enables sub-mesh level segmentation for FEM entities.

How Has This Been / Can This Be Tested?

  • tests/deformable/test_fem.py: the new test_multi_submesh_render_decoupling asserts exact per-vertex tracking between visual geoms and simulated vertices on a two-material GLB; test_interior_tetrahedralized_vertex checks the same invariant on a tetrahedralized box. The full file passes, including the implicit falling sphere/box rest-state checks.
  • tests/rendering/test_offscreen.py: the new test_multi_submesh_fem_render snapshot test covers rgb/depth/segmentation/normal on the rasterizer and rgb on the raytracer; test_segmentation_map covers the per-sub-mesh segmentation keys at "geom" level.
  • Genesis-Intelligence/snapshots updated to revision 11a81c48367a18aedf0a3bed460b69c7ba7ccd4e (5 new PNGs), pinned in tests/utils.py.

Screenshots (if appropriate):

Pair 1 - Ducks (Left Rigid, Right FEM)

Before After (This PR)
sbs_upstream sbs_ours

Pair 2 - Multi-sub-mesh FEM rendering (trashbag_rope.glb)

Before (uniform single surface) After (per-sub-mesh GLB materials)
trashbag_before trashbag_after

Checklist:

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of CONTRIBUTING document.
  • I tagged the title correctly (including BUG FIX/FEATURE/MISC/BREAKING)
  • I updated the documentation accordingly or no change is needed.
  • I tested my changes and added instructions on how to test it for reviewers.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

FEM entities expose their morph sub-meshes as visual geoms (FEMVisGeom),
each pairing a render mesh carrying its own surface and UVs with the map
from its vertices to the simulated vertices. The simulation operates on a
single welded copy of the sub-mesh vertices, tetrahedralized for volumetric
materials, while the rasterizer and raytracer draw the authored surfaces
and update them per visual geom. The FEM solver drops its render-only
topology and UV fields, and the normal render pass gains double-sided
support shared between offscreen and viewer renders.

Co-authored-by: Zhehuan Chen <acmlczh@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d880b403d3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 96 to +97
def _update_stress_noop(self, mu, lam, J, F, actu, m_dir):
raise NotImplementedError
return qd.Matrix.zero(gs.qd_float, 3, 3)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard cloth no-op stress outside IPC

When a FEM.Cloth entity is stepped in the default Scene configuration, the coupler is LegacyCouplerOptions, so FEMSolver.substep_pre_coupling() still runs compute_vel() over self.n_elements. Cloth is added only through _kernel_add_cloth(), which does not initialize elements_i.mass_scaled/tet data, and returning a zero stress here lets compute_vel() continue to dv = ... / mass_scaled with the default zero mass, producing NaNs instead of a clear unsupported-configuration failure. This only affects Cloth or other no-op FEM materials outside IPCCoupler; reject that setup before stepping or initialize/skip those elements rather than registering a zero-stress FEM material.

Useful? React with 👍 / 👎.

@duburcqa

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #2904, which keeps the original authorship: the consolidated changes are convention and API-surface alignment on top of an unchanged design. Both branches carry the same tree.

@duburcqa duburcqa closed this Jul 20, 2026
@duburcqa
duburcqa deleted the fem_render_decoupling branch July 20, 2026 11:06
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.

1 participant