Generated, typed, autocompletable Python API for composing Mitsuba scenes.
Project description
Mitsuba Scene Description (MSD)
Disclaimer: Expect rough edges and frequent changes to the API.
This package contains:
-
A core runtime API (
mitsuba_scene_description) with typed dataclasses, a recursive serializer, and a small sample of common plugins (BSDFs, shapes, sensors, emitters, integrators, textures). You can use this immediately to build scenes programmatically and callmi.load_dict(scene.to_dict()). -
A generator script (
generator/generate_mitsuba_api.py) that scrapes the official Mitsuba plugin reference and generates modules per category with conservative typing. Run it locally (with internet access) to create a complete API for all plugins.
Quick start (core API sample)
from pprint import pprint
import mitsuba as mi
mi.set_variant("llvm_ad_rgb")
import mitsuba_scene_description as msd
red = msd.SmoothDiffuseMaterial(reflectance=msd.RGB([0.8, 0.2, 0.2]))
ball = msd.Sphere(
radius=1.0,
bsdf=red,
to_world=msd.Transform().translate(0, 0, 3).scale(1.0, 1.0, 1.0),
)
cam = msd.PerspectivePinholeCamera(
fov=45,
to_world=msd.Transform().look_at(origin=[0, 1, -6], target=[0, 0, 0], up=[0, 1, 0]),
)
integrator = msd.PathTracer()
sun = msd.PointLightSource(
to_world=msd.Transform().translate(3, 4, 2), intensity=msd.RGB([3, 3, 3])
)
scene = msd.Scene(
integrator=integrator,
sensor=cam,
shapes={"ball": ball},
emitters={"sun": sun},
)
pprint(scene.to_dict())
mi_scene = mi.load_dict(scene.to_dict())
rndr = mi.render(mi_scene)
mi.util.write_bitmap("test.png", rndr)
Generate the full API from docs
- Install requirements:
pip install requests beautifulsoup4 - Run the generator:
python generator/generate_mitsuba_api.py --out gen --overview https://mitsuba.readthedocs.io/en/latest/src/plugin_reference.html
Notes
- The generator uses conservative typing by default (
Optional[Plugin]for unknown or nested plugin params). - You can tweak typing, categories, and output via CLI flags (
--aggressive,--single-file,--categories).
Roadmap
- Post-processing of generation using the tree-sitter API to remove artifacts
- Versioning
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mitsuba_scene_description-0.1.0.tar.gz.
File metadata
- Download URL: mitsuba_scene_description-0.1.0.tar.gz
- Upload date:
- Size: 40.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f980b2bad74ecf3258bcaf54173b9e081193039194ed0c333ef2ac42bdfcb697
|
|
| MD5 |
06eb4eff89ca6d1ffe96fa274d6496bc
|
|
| BLAKE2b-256 |
8f04d8964022605e6efad420a3ab6cda4f402ce349fe8862f5b8b5483610a818
|
File details
Details for the file mitsuba_scene_description-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mitsuba_scene_description-0.1.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c112bf58c02fdaf192b6f4d4d2707dffae1906e107a4e81f5945a20f5ff577f2
|
|
| MD5 |
d38579ab6336b72a7dcdc1d234aed0ac
|
|
| BLAKE2b-256 |
1161e7642c9c449dc4c5a66a9b2a490a80f9af2a7fe28055c1724bafb61f20fb
|