Implementation:Haosulab ManiSkill ShaderConfig
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Simulation, Rendering |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for defining shader pack configurations that control which textures and image modalities are rendered by cameras.
Description
The shaders.py module defines the ShaderConfig dataclass and a set of prebuilt shader configurations that determine how cameras in SAPIEN render their output textures. A shader config specifies the shader pack to use, which textures to render, and how to transform raw texture data into standard image modalities.
ShaderConfig dataclass:
shader_pack-- Name of the shader pack ("minimal", "default", "rt").texture_names-- Maps shader texture names to image modality lists (e.g., "Color" -> ["rgb"]).shader_pack_config-- Additional shader settings (e.g., ray tracing samples, path depth, denoiser).texture_transforms-- Functions that convert raw texture data into standard formats (rgb, depth, position, segmentation, normal, albedo).
Prebuilt configurations (PREBUILT_SHADER_CONFIGS):
- "minimal" -- Fast, minimal rendering with combined PositionSegmentation texture (uint16).
- "default" -- Standard rendering with separate Color, Position, Segmentation, Normal, Albedo textures (float32).
- "rt" -- High-quality ray tracing (32 samples/pixel, depth 16, OptiX denoiser).
- "rt-med" -- Medium-quality ray tracing (4 samples/pixel, depth 3).
- "rt-fast" -- Fast ray tracing (2 samples/pixel, depth 1).
set_shader_pack(): Applies a shader config globally for the SAPIEN 3.0 render system, configuring picture formats and ray tracing parameters.
Usage
Shader configs are selected via the environment's shader_dir parameter or camera configuration. The prebuilt configs cover the most common use cases.
Code Reference
Source Location
- Repository: Haosulab_ManiSkill
- File: mani_skill/render/shaders.py
Signature
@dataclass
class ShaderConfig:
shader_pack: str
texture_names: dict[str, list[str]] = field(default_factory=dict)
shader_pack_config: dict[str, Any] = field(default_factory=dict)
texture_transforms: dict[str, Callable[[torch.Tensor], dict[str, torch.Tensor]]] = field(default_factory=dict)
PREBUILT_SHADER_CONFIGS: dict[str, ShaderConfig]
def set_shader_pack(shader_config: ShaderConfig) -> None: ...
Import
from mani_skill.render.shaders import ShaderConfig, PREBUILT_SHADER_CONFIGS, set_shader_pack
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| shader_pack | str | Yes | Shader pack name ("minimal", "default", "rt") |
| texture_names | dict | No | Map of texture names to image modality lists |
| shader_pack_config | dict | No | Additional shader-specific settings |
| texture_transforms | dict | No | Functions to transform raw texture data |
Outputs
| Name | Type | Description |
|---|---|---|
| ShaderConfig | ShaderConfig | Configuration object for the shader pack |
| image modalities | dict[str, torch.Tensor] | Transformed image data (rgb, depth, position, etc.) |
Usage Examples
Basic Usage
from mani_skill.render.shaders import PREBUILT_SHADER_CONFIGS, set_shader_pack
# Use the default shader
shader_config = PREBUILT_SHADER_CONFIGS["default"]
set_shader_pack(shader_config)
# Use ray tracing for high-quality rendering
rt_config = PREBUILT_SHADER_CONFIGS["rt"]
set_shader_pack(rt_config)