Skip to main content

shadewire

Compile MaterialX materials and Blender material graphs to shader code from Python: WGSL, GLSL (desktop and ES), HLSL and Metal, each with the reflection a renderer needs to bind them. The compiler is Rust (Shadewire); one wheel per platform serves every CPython from 3.8.

pip install shadewire
from shadewire import mtlx, glsl

text = open("material.mtlx", encoding="utf-8").read()
ir = mtlx.to_ir(text, location="material.mtlx")      # the material in Shadewire's IR
compiled = glsl.compile(ir, version=420)         # or shadewire.wgsl / .hlsl / .msl
print(compiled.code)                             # the model's struct, shadewire_eval_surface(), ...
print(compiled.reflection["uniforms"])           # offsets and defaults of the uniform block
print(compiled.reflection["textures"])           # files, colorspaces, bindings
  • shadewire.mtlx: to_ir(text, location=None, material=None, models=None, ...) and material_names(text, location=None). models lists the shading models the renderer accepts: standard_surface, open_pbr_surface, gltf_pbr, surface_unlit, and surface, the material as a closure tree of MaterialX's lobes (raw BSDF graphs included). resolver= reads xi:includes your way: a callable (base, href) -> (location, text) that raises to fail (None reads the file system relative to location). list_dependencies(text, location=None) returns a document's {"includes": [...], "files": [...]}, so a host with its own I/O can fetch everything first:

    def resolve(base, href):                         # locations are opaque strings: paths, URLs, archive members
        location = base.rsplit("/", 1)[0] + "/" + href
        return location, fetched[location]           # a KeyError fails the compile with its message
    
    ir = mtlx.to_ir(text, location="https://example.com/m.mtlx", resolver=resolve)
    
  • shadewire.blender: to_ir(text, material=None, models=None, ...) and material_names(text) read a Blender material graph (the JSON the Blender extension's File > Export > Material Graph writes): a Principled BSDF becomes open_pbr_surface, other BSDFs a closure tree (accept surface in models). What the front end dropped or approximated, one line per node, is in Ir.warnings:

    ir = blender.to_ir(open("material.json", encoding="utf-8").read(), models=["open_pbr_surface", "surface"])
    for warning in ir.warnings:                      # 'ShaderNodeBevel "Bevel": not lowered, output Normal ...'
        print(warning)
    
  • shadewire.mdl: to_ir(text, material=None, models=None, ..., paths=None, location=None) and material_names(text, paths=None, location=None) read an NVIDIA MDL module (paths is the MDL search path); an MDL material is a closure tree, so models must accept surface. compile(ir, name="material") writes the IR as a self-contained MDL 1.7 module:

    ir = mdl.to_ir(open("material.mdl", encoding="utf-8").read(), models=["surface", "surface_unlit"], paths=["mdl"])
    module = mdl.compile(mtlx.to_ir(text, models=["surface", "surface_unlit"]), name="wood").code
    
  • shadewire.Ir: optimize(), dump(), to_dict() (the IR as a JSON-like document), model, structure_hash, warnings.

  • shadewire.wgsl, shadewire.glsl, shadewire.hlsl, shadewire.msl: compile(ir, ...) returns a shadewire.Compiled with code, language, reflection and model_struct.

The generated code calls host functions (shadewire_host_normal_world(), shadewire_host_texcoord_0()...) that the renderer defines next to its lights; for a material with lobes it also evaluates them as MaterialX defines (shadewire_eval_bsdf, shadewire_eval_albedo, shadewire_eval_emission, and shadewire_eval_ambient, the albedo split into diffuse and specular for a host with its own environment lighting). The repository's crates/shadewire-py/examples has complete renderers: OpenGL with pygame (a host lighting MaterialX's lobes, and one with its own PBR over the named models) and wgpu-py.

Licensed MIT; parts port MaterialX (Apache-2.0) and Open Shading Language (BSD-3-Clause): see NOTICE.

Metadata

Release files for shadewire 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shadewire 0.3.0
File Size Uploaded Provenance Actions
shadewire-0.3.0.tar.gz 936.8 kB Without provenance Details for shadewire-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for shadewire 0.3.0
File Actions
shadewire-0.3.0-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details for shadewire-0.3.0-cp38-abi3-win_arm64.whl
shadewire-0.3.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for shadewire-0.3.0-cp38-abi3-win_amd64.whl
shadewire-0.3.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for shadewire-0.3.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
shadewire-0.3.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for shadewire-0.3.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
shadewire-0.3.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for shadewire-0.3.0-cp38-abi3-macosx_11_0_arm64.whl
shadewire-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for shadewire-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 14.5 MB

Release files / shadewire-0.3.0.tar.gz

Download URL shadewire-0.3.0.tar.gz
Size 936.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7bd1ce2c7e9eb3b1693d81d8d094b9f214d4cbecf7f8fdfe201556fdc5187cbd
BLAKE2b-256 checksum
How to use checksums
9a200d9c69ca51e98d356e1800bb65f30fe1bea705a63c6c6fbd98c909c3cf9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-win_arm64.whl

Download URL shadewire-0.3.0-cp38-abi3-win_arm64.whl
Size 2.1 MB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
639b26649c66c4f60434c81ca39a77567646fbdded6e054cc9466e8cb4398b93
BLAKE2b-256 checksum
How to use checksums
16ebd7b2be5fd8665f7024c900d70e0361b52ef7dd5883019dec3fccfaefd10f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-win_amd64.whl

Download URL shadewire-0.3.0-cp38-abi3-win_amd64.whl
Size 2.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dfdca3bb7d1ca34849cf38ddca71e7d1756e1540f968878670bbcb6f40a08f1a
BLAKE2b-256 checksum
How to use checksums
3ea13a1c6b6d1d7b3f03a93327a0e945f7e6eb76240b0f9e15e3d50fee560d7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL shadewire-0.3.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.3 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
5d5a9627ee136ab9091390372d4cdac2d6f2c35cb282dfd39dd2783093d4039d
BLAKE2b-256 checksum
How to use checksums
e93654b78aaff92750db78597162a3efdc08eb66a39047d0f2d33738dec2187d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL shadewire-0.3.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.1 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
72d2cc4fdab89fc84147c75debadafe559e32b2ad952b8c3684c4df299d4236c
BLAKE2b-256 checksum
How to use checksums
21e476d37f45c2b0bfbc2cf51e55a681d7f72b5f5039ed480205295e9c36ea0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL shadewire-0.3.0-cp38-abi3-macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c22d6c2f6f77da4da70dc05f66cb6483330b27ee09eb6092f01d2217e4c4abb5
BLAKE2b-256 checksum
How to use checksums
3ae7d3677f2cac2cc6fbbd815d66ff9b2fddb5c2b07dcefab63409059e56ea77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / shadewire-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL shadewire-0.3.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
390a14d5e7184ce55d36a50b0e4b880bcb494c14138bde749e5fd9d49245cef7
BLAKE2b-256 checksum
How to use checksums
82a71bf81c4ef9da508c90f4680ef6b79bc5e7b35ccf9382649ed6acfdfa82e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for shadewire 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page