Skip to main content

shadewire

Compile MaterialX materials 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.Ir: optimize(), dump(), to_dict() (the IR as a JSON-like document), model, structure_hash.

  • 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). 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.1.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.1.0
File Size Uploaded Provenance Actions
shadewire-0.1.0.tar.gz 527.4 kB Without provenance Details for shadewire-0.1.0.tar.gz

Built distributions (wheels)

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

Total release size: 8.3 MB

Release files / shadewire-0.1.0.tar.gz

Download URL shadewire-0.1.0.tar.gz
Size 527.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d440f1127641f6cb7f35696a8ea1271c6db181af808cefbdd4328a213766a5f7
BLAKE2b-256 checksum
How to use checksums
65aa24291af71b3db110c5aaa951356846f61a1195dc9d3439fa7ffaf2ce8b1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-win_arm64.whl
Size 1.0 MB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
c89110c4e22c13638ddaf5acf826c379aa7b2aa61d6fa7ea4ba8eb63b3ce8aa3
BLAKE2b-256 checksum
How to use checksums
d9f43084b5b0d5840438af486f5d878186dc5e182394b8a6067187fd1930e656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f0b614163fdb079c0dee23e29353db301b6beb5aab8d4a28a1b73f51e9f20ef5
BLAKE2b-256 checksum
How to use checksums
4f7644a17a323d229c38f1b32b87ad5f4bbd0b804f16a648ef9e2b89163b3b69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
29de0a006779fb150d0bcc70afa1906c2f5bcaaac0e3817b9743e07aa2cb7ef6
BLAKE2b-256 checksum
How to use checksums
7f4028bcd5f0b467627ffa3f022e97c49e548bfddb5b1c6e206b957e76c54dc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.1 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
8646fa5958e710fbc2f27c7be1365c15fb7053db6736a2a603018436acfa4c89
BLAKE2b-256 checksum
How to use checksums
79a3a74287219f1334ce705506d2b833023e2298d565186b8f93e617a365a966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8d20d7986eb203171034b1a2c376750412130620a8723577e16e1385e64a3f43
BLAKE2b-256 checksum
How to use checksums
9393a7cd83b0d88f58a44c53f7c6a75e21429277766ac01953f9ff447e4ca51e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

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

Download URL shadewire-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 1.7 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
c668628c44236d6044443592163d49083b7d67ec0bf0b09b44c2972622560b4c
BLAKE2b-256 checksum
How to use checksums
c7ed975a5d6fc224ab686563005d62243849c92af991a4e17d4ea0085cd7c315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for shadewire 0.1.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