google-deepmind / google-deepmind/mujoco

Feature request: per-geom wireframe rendering mode

Open
#3,181 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
15.2k
Forks
1.8k
Avg merge
10d 16h
Merged PRs (30d)
25

Description

## Enhancement suggestion

**Current behavior:** `mjRND_WIREFRAME` is a global flag that renders ALL geoms as wireframe. There is no way to selectively render individual geoms as wireframe while keeping others solid.

**Desired behavior:** A per-geom `wireframe` field on `mjvGeom` that controls wireframe rendering independently of the global flag:
- `0`: normal solid rendering (default, no behavior change)
- `1`: solid + wireframe overlay on top
- `2`: wireframe only (skip solid pass)

**Why this is useful:** Debugging collision meshes, visualizing height field grids, inspecting soft body topology, or showing mesh structure for specific geoms while keeping the rest of the scene visually clean. Currently the only options are all-wireframe or no-wireframe.

**Proof of concept:** I have a working implementation at https://github.com/stanbot8/mujoco/tree/feature/per-geom-wireframe

The change is small (2 files, ~40 lines):
1. Add `mjtByte wireframe` to `mjvGeom` struct (defaults to 0 via existing memset)
2. Add a wireframe overlay pass in `renderGeom` flow in `render_gl3.c` that uses `glPolygonOffset` to draw wireframe lines on top of selected geoms

Usage from user code:
```c
mjv_updateScene(m, d, &opt, NULL, &cam, mjCAT_ALL, &scn);
// Find a geom and enable wireframe overlay
for (int i = 0; i < scn.ngeom; i++) {
if (scn.geoms[i].objtype == mjOBJ_GEOM && scn.geoms[i].objid == my_geom_id) {
scn.geoms[i].wireframe = 1; // overlay
}
}
mjr_render(viewport, &scn, &con);
```

Happy to write tests and follow the style guide if there is interest in this feature. Would also be interested in discussing whether this should extend to XML/mjSpec or remain visualization-only.

**Platform:** Windows 10, MuJoCo latest main branch

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.