[FEATURE] Decouple FEM render geometry from sim geometry (multi-sub-mesh + double-sided normal pass)#2904
Draft
ACMLCZH wants to merge 7 commits into
Draft
[FEATURE] Decouple FEM render geometry from sim geometry (multi-sub-mesh + double-sided normal pass)#2904ACMLCZH wants to merge 7 commits into
ACMLCZH wants to merge 7 commits into
Conversation
Introduce a `render_meshes` + `sim_vert_maps` model on FEMEntity so the visualizer can draw the user's original input surface (multi-sub-mesh GLBs supported) while the FEM solver retains its own tet-boundary topology for physics. Changes: - FEMEntity.sample() builds `_render_meshes` (list[gs.Mesh]) and `_sim_vert_maps` (list[np.ndarray]) via `gs.Mesh.from_morph_surface` and a new `_merge_elements` helper that dedupes vertices across sub-meshes and remaps element indices. - FEM solver drops the `surface_render_f` (triangle-indices) and `surface_render_uvs` (per-vertex UV) fields; rendering topology / UVs now live on FEMEntity's per-sub-mesh `Mesh` objects. - `get_state_render(f)` returns sim vertex positions only. - Rasterizer + raytracer iterate per-sub-mesh and key static nodes by `(env_idx, entity.uid, sub_idx)`. - `mesh_to_elements` signature change: accepts a trimesh directly, returns (verts, elems) only (UVs come from the input render mesh). - `gs.Mesh.from_morph_surface` returns a list for primitive morphs too — uniform return type makes consumers simpler. - `test_interior_tetrahedralized_vertex` updated to assert the new invariant: viz vertices = sim_verts[sim_vert_maps[0]].
…-world into pr/fem-render-meshes
duburcqa
reviewed
Jun 6, 2026
Collaborator
There was a problem hiding this comment.
Reduce the diff. It should not be this large. You made something wrong in your commit.
duburcqa
reviewed
Jun 6, 2026
| def mesh_to_elements(mesh, tet_cfg=dict()): | ||
| tet_file_path = mu.get_tet_path(mesh.vertices, mesh.faces, tet_cfg) | ||
|
|
||
| # loading pre-computed cache if available |
Collaborator
There was a problem hiding this comment.
Do not remove comments that are still applicable.
duburcqa
reviewed
Jun 6, 2026
Comment on lines
+90
to
+98
| # Verify that the visualizer mesh's vertices correctly track the FEM sim's | ||
| # surface vertices through `fem.sim_vert_maps`. The visualizer mesh | ||
| # (`render_meshes[0]`) holds the *pre-tet-split* input surface (e.g. 12 box | ||
| # triangles), while `fem.surface_triangles` is computed from the *post-split* | ||
| # tetrahedral elements (with mid-edge Steiner subdivisions). The two meshes | ||
| # differ in granularity *by design* — so comparing triangle sets is not the | ||
| # right invariant. The correct invariant is that the renderer's per-vertex | ||
| # buffer updates from `sim_verts[svm]` produce vertex positions consistent | ||
| # with the sim state. |
Collaborator
There was a problem hiding this comment.
You are wrapping comments too early.
…-world into pr/fem-render-meshes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouple FEM rendering geometry from simulation geometry.
FEMEntitynow carriesrender_meshes: list[gs.Mesh]andsim_vert_maps: list[np.ndarray].sim_vert_mapsis used to map rendering vertices inrender_meshesto simulation vertices fromFEMSolver.FEMEntityalso support segmentation ingeomlevel.[BUG FIX] Support double-sided normal shader for pyrender
Visual
Pair 1 — Ducks (Left Rigid, Right FEM)
Pair 2 — multi-geom FEM rendering (Trashbag_rope.glb)
Before: a uniform user-supplied surface is applied to the whole entity — what the pre-PR solver-side rendering produced (one
entity.surfacefor all sub-meshes). After: each sub-mesh keeps its own GLB material viarender_meshes— the channel's yellow rim is now distinct from the bag body.Snapshots
Genesis-Intelligence/snapshotsupdated →4910d05d2a40de6890263bf92376b389d660d7fb(6 PNGs across 2 commits).tests/utils.py:HUGGINGFACE_SNAPSHOT_REVISIONbumped to match.Next Step
render_meshes.render_meshes.Test plan
pytest tests/test_fem.py— all 6 parametrizes pass against the new render_meshes structure.pytest tests/test_render.py— 64 passed; the multi-sub-mesh FEM render snapshots (rgb/depth/seg/normal) pass via HF revision pin; updatedtest_segmentation_mapformula at"geom"level accounts for per-sub-mesh FEM seg tuples.