Skip to content

Extract built-in shader packages for editor tooling. - #271

Open
tychedelia wants to merge 1 commit into
mainfrom
py-shader-packages
Open

tychedelia wants to merge 1 commit into
mainfrom
py-shader-packages

Conversation

@tychedelia

@tychedelia tychedelia commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Objective

When users install our wheel via pypi, we need a way for them to be able to access the shader source for shader tooling via wgsl-analyzer.

This allows the root processing_py module to function as a CLI and adds a new command that allows users to create a wesl.toml:

python -m processing_py shaders init

Testing

Needs uv and a recent wgsl-analyzer (the editor extension, or a build from this year; older builds don't read
wesl.toml dependencies).

  1. Build a wheel from this branch:

    gh pr checkout 271
    git submodule update --init
    cd crates/processing_pyo3
    uv run maturin build --release -o /tmp/pp-wheel
    
  2. Make a fresh project and install it:

    mkdir /tmp/shader-demo && cd /tmp/shader-demo
    uv venv && uv pip install /tmp/pp-wheel/*.whl
    
  3. Write the shader packages and the manifest:

    .venv/bin/python -m processing_py shaders init
    cat wesl.toml
    

    Expect a wesl.toml with processing and lygia path dependencies pointing into
    .venv/share/processing_py/shaders/.

  4. Add a shader that imports from both packages, as shaders/noise.wesl:

    import { lygia::generative::snoise::snoise33 };
    import { processing::{globals, VertexOutput} };
    
    @group(3) @binding(0) var<uniform> color: vec4<f32>;
    
    @fragment
    fn fragment(mesh: VertexOutput) -> @location(0) vec4<f32> {
        let p = mesh.world_position.xyz * 0.02 + globals.time * 0.1;
        let n = snoise33(p) * 0.5 + 0.5;
        return vec4(vec3(n), 1.0) * color;
    }

    Open the folder in an editor with wgsl-analyzer. Go-to-definition on snoise33 and VertexOutput should jump
    into .venv/share/processing_py/shaders/, with no unresolved-import errors.

  5. Check the runtime resolves the same imports. Save as sketch.py and run .venv/bin/python sketch.py:

    from processing_py import *
    
    mat = None
    
    def setup():
        global mat
        size(400, 300)
        mode_3d()
        mat = create_material(load_shader("shaders/noise.wesl"), color=[1.0, 0.2, 0.4, 1.0])
    
    def draw():
        camera_position(0.0, 0.0, 200.0)
        camera_look_at(0.0, 0.0, 0.0)
        background(12, 12, 18)
        material(mat)
        box(80.0, 80.0, 80.0)
    
    run()

    Expect a box shaded with animated noise.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@tychedelia
tychedelia added this pull request to stack #277 November 13, 2026 01:16
@tychedelia
tychedelia requested a review from catilac November 13, 2026 01:33
@tychedelia
tychedelia marked this pull request as ready for review November 13, 2026 01:33
@github-actions

Copy link
Copy Markdown

Visual regression: 1 changed of 43 cases

case status detail
py_flocking_gpu ❌ changed 7.99% of pixels differ

If these changes are intentional, add the deliberate-rendering-change label.

baseline 21a2dda7ac · adapter llvmpipe (LLVM 20.1.2, 256 bits) (Vulkan, Mesa 25.2.8-0ubuntu0.24.04.4 (LLVM 20.1.2))

Open the visual report · workflow run

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant