mujoco-rendering
Skill15k starsChanged 3 months agoApache-2.0View on GitHub
Offscreen image rendering, Python Renderer class, C++ pipeline (mjrContext, mjvScene, mjr_render, mjr_readPixels), RGB, metric depth maps, segmentation masks (mjtObj), offwidth/offheight framebuffer sizing, MUJOCO_GL (osmesa, egl), cameras (fixed, tracking, free, MjvCamera), scene options (geomgroup, flags). Use for headless camera rendering, dataset recording, visual observations. Do NOT use for interactive viewers/Studio (mujoco-studio) or ImGui controls (mujoco-gui).
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about google-deepmind/mujoco
- A Hacker News story“MuJoCo – Advanced Physics Simulation”Hacker News · Apr 19, 2026 · 116 points
- openai/mujoco-py“Cannot change site position programmatically when pos is set to zero in XML”GitHub · Mar 7, 2024 · 7 reactions
- dtcxzyw/llvm-opt-benchmark“Wishlist for new benchmarks”GitHub · Jan 17, 2024 · 5 reactions
- astral-sh/uv“MuJoCo `mjpython` fails with uvx”GitHub · Nov 8, 2024 · 4 reactions
- jrouwe/JoltPhysics“[Feature Request] Soft-soft collisions and self-collisions”GitHub · Dec 12, 2023 · 4 reactions
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on GitHub, Hacker News and Bluesky (13 times).
On GitHub · 10
- Mar 7, 2024Cannot change site position programmatically when pos is set to zero in XML — openai/mujoco-py7 reactions
- Jan 17, 2024Wishlist for new benchmarks — dtcxzyw/llvm-opt-benchmarksays it tested it5 reactions · 15 comments
- Nov 8, 2024MuJoCo `mjpython` fails with uvx — astral-sh/uv4 reactions · 7 comments
- Dec 12, 2023[Feature Request] Soft-soft collisions and self-collisions — jrouwe/JoltPhysics4 reactions · 5 comments
- Jul 22, 2026passive adhesion — google-deepmind/mujoco_warp3 reactions · 1 comment
5 more on GitHub
- Aug 26, 2026Fix JAX FFI VMA propagation — NVIDIA/warp2 reactions · 6 comments
- Oct 31, 20251st party WASM bindings are now available for Alpha testing — zalo/mujoco_wasmsays it tested it2 reactions · 21 comments
- Aug 7, 2025reset_data — google-deepmind/mujoco_warp2 reactions · 1 comment
- Dec 27, 2025fix: CGL: try to init pixel format without explicit profile before falling back to profile selection — rust-windowing/glutin1 reaction · 3 comments
- Nov 8, 2024Fix glfw name when using system installed version — google-deepmind/mujoco_mpc1 reaction · 1 comment
On Hacker News · 2
- Apr 19, 2026MuJoCo – Advanced Physics Simulation116 points · 24 comments
- Oct 18, 2023MuJoCo 31 point
On Bluesky · 1
- Apr 22, 2026MuJoCo – Advanced Physics Simulation Discussion — @hn100.bsky.social1 likes and repost
In this repository5 other files it gives its agents.
- mujoco-acceleratedSkill
- mujoco-guiSkill
- mujoco-pythonSkill
- mujoco-spec-editingSkill
- mujoco-studioSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 240
GL context leaks: Always close the renderer or use a with block.
- Distinctive: line 247
Avoid passing raw string IDs that are not present in the model.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MuJoCo Rendering: Cameras, Contexts & Offscreen Buffers
[!TIP]
Related skills:
- mujoco-python — Core physics simulation, stepping, and state management.
- mujoco-studio — Interactive simulation, Studio viewer apps, and plugin architecture.
- mujoco-gui — Dear ImGui UI design and custom controls.
1. Overview: Headless vs Interactive Rendering
MuJoCo provides two distinct graphics workflows:
- Headless Offscreen Rendering (
mujoco.Renderer/mjrContext): Focused on capturing image buffers (RGB, depth, object segmentation) without opening a desktop window. Ideal for batch dataset collection, reinforcement learning observations, and automated visual regression testing. - Interactive Viewers (
mujoco.experimental.studio/mujoco.viewer): Interactive desktop or web-streamed applications designed for real-time inspection, camera manipulation, and Dear ImGui control panels.
2. Headless Contexts on Linux: MUJOCO_GL
On headless Linux systems (servers, containers), configure the OpenGL context
provider via the MUJOCO_GL environment variable before importing mujoco:
import os
os.environ['MUJOCO_GL'] = 'egl' # Hardware-accelerated offscreen on NVIDIA GPUs
# os.environ['MUJOCO_GL'] = 'osmesa' # Portable CPU software rasterization
import mujoco # Must import AFTER setting MUJOCO_GLOr from the command line:
MUJOCO_GL=egl python3 my_script.py3. The Python Renderer Class (RGB, Depth & Segmentation)
mujoco.Renderer manages GL context creation, scene geometry synchronization,
and buffer readback. Always use it as a context manager:
import mujoco
import numpy as np
model = mujoco.MjModel.from_xml_path('scene.xml')
data = mujoco.MjData(model)
with mujoco.Renderer(model, height=480, width=640) as renderer:
mujoco.mj_forward(model, data)
# 1. RGB Rendering
renderer.update_scene(data, camera='overhead_cam')
rgb = renderer.render() # Shape: (480, 640, 3), dtype: uint8
# 2. Metric Depth Rendering (distance in meters)
renderer.enable_depth_rendering()
renderer.update_scene(data, camera='overhead_cam')
depth = renderer.render() # Shape: (480, 640), dtype: float32
renderer.disable_depth_rendering()
# 3. Semantic Segmentation Rendering
renderer.enable_segmentation_rendering()
renderer.update_scene(data, camera='overhead_cam')
seg = renderer.render() # Shape: (480, 640, 2), dtype: int32
# seg[:, :, 0] = object ID (-1 for background)
# seg[:, :, 1] = object type (mjtObj enum, e.g. mjOBJ_GEOM)
renderer.disable_segmentation_rendering()Rendering Inside Simulation Loops
Creating a Renderer allocates GPU framebuffers. In RL or evaluation loops,
create the renderer once outside the loop:
with mujoco.Renderer(model, height=84, width=84) as renderer:
for step in range(1000):
mujoco.mj_step(model, data)
if step % render_interval == 0:
renderer.update_scene(data, camera='agent_cam')
# Call .copy() because the renderer's internal buffer is reused
frame = renderer.render().copy()4. C++ Offscreen Rendering Pipeline (mjr & mjv)
In C++, offscreen rendering is performed using the mjvScene and mjrContext
APIs:
#include <mujoco/mujoco.h>
// 1. Initialize visualization structures
mjvCamera cam;
mjv_defaultCamera(&cam);
cam.type = mjCAMERA_FIXED;
cam.fixedcamid = mj_name2id(m, mjOBJ_CAMERA, "overhead_cam");
mjvOption opt;
mjv_defaultOption(&opt);
mjvScene scn;
mjv_makeScene(m, &scn, 2000); // Buffer up to 2000 geoms
// 2. Initialize offscreen rendering context
mjrContext con;
mjr_defaultContext(&con);
mjr_makeContext(m, &con, mjFONTSCALE_100);
// 3. Render frame
mjrRect viewport = {0, 0, 640, 480};
mjv_updateScene(m, d, &opt, nullptr, &cam, mjCAT_ALL, &scn);
mjr_render(viewport, &scn, &con);
// 4. Read pixels into user buffers
unsigned char rgb[640 * 480 * 3];
float depth[640 * 480];
mjr_readPixels(rgb, depth, viewport, &con);
// 5. Clean up
mjr_freeContext(&con);
mjv_freeScene(&scn);5. Camera Definition & Placement
MuJoCo cameras look down their negative Z-axis:
- -Z: Viewing forward direction
- +X: Right
- +Y: Up
Defining Cameras in MjSpec
# Fixed camera pointing down at ground plane
cam = spec.worldbody.add_camera(
name='overhead',
pos=[0, 0, 3.0],
quat=[0.707, 0.707, 0, 0], # 90 deg rotation around X
fovy=60,
)
# Camera attached to robot wrist
wrist_cam = wrist_body.add_camera(
name='wrist_cam',
pos=[0.05, 0, 0],
xyaxes=[0, -1, 0, 0, 0, -1],
fovy=75,
)Free Camera (MjvCamera)
For custom interactive or orbital viewpoints:
cam = mujoco.MjvCamera()
cam.type = mujoco.mjtCamera.mjCAMERA_FREE
cam.lookat[:] = [0, 0, 0.5]
cam.distance = 2.5
cam.azimuth = 90.0
cam.elevation = -20.0
renderer.update_scene(data, camera=cam)6. Framebuffers & Scene Options
Offscreen Framebuffer Resolution
The offscreen rendering resolution cannot exceed the dimensions pre-allocated in the model. Adjust the buffer limit in the spec before compilation:
spec.visual.global_.offwidth = 1920
spec.visual.global_.offheight = 1080
model = spec.compile()The Single <visual> Block Rule
MuJoCo uses only the last <visual> block defined in an XML file. Multiple
visual blocks will silently overwrite earlier settings:
<!-- ❌ WRONG — second visual block silently resets offwidth/offheight to default -->
<visual><global offwidth="1920" offheight="1080"/></visual>
<visual><headlight ambient="0.3 0.3 0.3"/></visual>
<!-- ✅ RIGHT — consolidate into one visual block -->
<visual>
<global offwidth="1920" offheight="1080"/>
<headlight ambient="0.3 0.3 0.3"/>
</visual>Geom Group Visibility & Visualization Flags
Control rendering layers via MjvOption:
opt = mujoco.MjvOption()
opt.geomgroup[:] = False # Hide all groups
opt.geomgroup[0] = True # Show primary geometry (default group)
opt.geomgroup[1] = True # Show secondary visuals
# Toggle visual debugging flags
opt.flags[mujoco.mjtVisFlag.mjVIS_CONTACTFORCE] = True
opt.flags[mujoco.mjtVisFlag.mjVIS_TRANSPARENT] = True
renderer.update_scene(data, camera='overhead', scene_option=opt)7. Filament & Modern Graphics Backends
MuJoCo supports the Filament physically-based rendering (PBR) engine
experimentally for advanced lighting, soft shadows, and materials. In Python,
Filament renderer bindings are available under mujoco.rendering.filament.
8. Common Gotchas & Best Practices
- GL context leaks: Always close the renderer or use a
withblock. Failing to free renderers in loops exhausts GL contexts. - Destruction order: In C++,
mjr_freeContextmust be called before the underlying OpenGL context is destroyed. - Buffer re-use:
renderer.render()returns an internal buffer view. Call.copy()if storing frames in a list. - Camera lookup by name: Pass
camera='camera_name'or the integer ID. Avoid passing raw string IDs that are not present in the model.
9. Key References
Documentation
- Visualization & Rendering Reference
- Python Bindings Reference
Source Code Examples
- C API Header
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

