Skip to main content

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:

  1. 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 call mi.load_dict(scene.to_dict()).

  2. 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

  1. Install requirements: pip install requests beautifulsoup4
  2. 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

mitsuba_scene_description-0.1.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mitsuba_scene_description-0.1.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file mitsuba_scene_description-0.1.0.tar.gz.

File metadata

File hashes

Hashes for mitsuba_scene_description-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f980b2bad74ecf3258bcaf54173b9e081193039194ed0c333ef2ac42bdfcb697
MD5 06eb4eff89ca6d1ffe96fa274d6496bc
BLAKE2b-256 8f04d8964022605e6efad420a3ab6cda4f402ce349fe8862f5b8b5483610a818

See more details on using hashes here.

File details

Details for the file mitsuba_scene_description-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mitsuba_scene_description-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c112bf58c02fdaf192b6f4d4d2707dffae1906e107a4e81f5945a20f5ff577f2
MD5 d38579ab6336b72a7dcdc1d234aed0ac
BLAKE2b-256 1161e7642c9c449dc4c5a66a9b2a490a80f9af2a7fe28055c1724bafb61f20fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page