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.unreal: to_ir(text, material=None, models=None, ...) and material_names(text) read an Unreal material graph (the JSON the Unreal plugin's commandlet writes with -format=json): a legacy-shading material becomes open_pbr_surface (Unlit surface_unlit), its parameters uniforms; warnings as for Blender.

  • shadewire.mdl: to_ir(text, material=None, models=None, ..., paths=None, location=None, distill=False, arguments=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 (or open_pbr_surface with distill). arguments, (name, value) pairs, replace parameter defaults: a bool, an int, a float, 2 to 4 floats, a str or {"texture": path, "colorspace": "sRGB"}. 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.4.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.4.0
File Size Uploaded Provenance Actions
shadewire-0.4.0.tar.gz 1.0 MB Without provenance Details for shadewire-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for shadewire 0.4.0
File Actions
shadewire-0.4.0-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details for shadewire-0.4.0-cp38-abi3-win_arm64.whl
shadewire-0.4.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for shadewire-0.4.0-cp38-abi3-win_amd64.whl
shadewire-0.4.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.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
shadewire-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for shadewire-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
shadewire-0.4.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for shadewire-0.4.0-cp38-abi3-macosx_11_0_arm64.whl
shadewire-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for shadewire-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 17.7 MB

Release files / shadewire-0.4.0.tar.gz

Download URL shadewire-0.4.0.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
59e66b6eaff91f51e5a88006bee406495df3f04a212483b38e762fa9d898ee0f
BLAKE2b-256 checksum
How to use checksums
b543ff74c7dd2a9e129399e5ec3d296d8c44f7c718058756fcf032f53e433556
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.4.0-cp38-abi3-win_arm64.whl

Download URL shadewire-0.4.0-cp38-abi3-win_arm64.whl
Size 3.1 MB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
d1a7c8f045af9b14535aef77597f0c8f1945682cc1fcea97d2611b5f45260674
BLAKE2b-256 checksum
How to use checksums
0ff3a53ab918c36df6cfd3d8082a81732638a98197aa9584c9da3e597150e31f
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.4.0-cp38-abi3-win_amd64.whl

Download URL shadewire-0.4.0-cp38-abi3-win_amd64.whl
Size 3.3 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
952e30fd6dd213410a11e562c67cb26fa043b520215b5230a3cc4997ea81a445
BLAKE2b-256 checksum
How to use checksums
d14f3cc2ae5ea2bd1491d8ed5da492fc10198d99b6516fea184e06f679027794
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.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL shadewire-0.4.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
167436d0d6b197cd62cf373f73460f4163a026d8d970af53f352c38d526ea83c
BLAKE2b-256 checksum
How to use checksums
d135fef36b862b083d63fd354f58b81d8c6823a0d5cbe1d7ca9a8251b8e76ab1
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.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL shadewire-0.4.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c875bc6488898a2ae47055d169f15efb776a25d7ac644324bf5fe64f3e753ea6
BLAKE2b-256 checksum
How to use checksums
1e9f7b76c0692949a5c82907b4025b31d961dbf811a1563e7f82f09de16013f5
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.4.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL shadewire-0.4.0-cp38-abi3-macosx_11_0_arm64.whl
Size 2.6 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b6358019a4994b1af440b0e01ddb664a4f1bf4192c54d8cd7585aa06a57fbbf
BLAKE2b-256 checksum
How to use checksums
79b0edc000b92abb9c486a5a023322bea9d0f114ec8761037a077c61cdb19127
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.4.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL shadewire-0.4.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 2.7 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
dad61e83f3ec72dc0606746c2e5f8b3e674ea6964c37ea418e42992463c00069
BLAKE2b-256 checksum
How to use checksums
0daae6e1bc34fca4ef336f0bdc3b37c93866c0e4ee127bd3429c1b7687406fd4
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.4.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