First draft of per-pixel color evaluation - #461
Open
mkeeter wants to merge 10 commits into
Open
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved shader correctness and color API issues can produce transparent output, incorrect effects, or unreported shape mismatches.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds WebGPU per-pixel color-expression evaluation to the voxel rendering pipeline.
Changes:
- Adds color-expression buffers, bytecode input remapping, and a color compute pass.
- Relocates voxel effects and updates shading to consume computed colors.
- Adds shader-layout and GPU pipeline tests.
File summaries
| File | Description |
|---|---|
fidget-wgpu/src/voxel/mod.rs |
Exposes effects and expands pipeline tests. |
fidget-wgpu/src/voxel/effects/mod.rs |
Implements color buffers, submission, and shading integration. |
fidget-wgpu/src/voxel/effects/shaders/color.wgsl |
Evaluates RGB expressions per pixel. |
fidget-wgpu/src/voxel/effects/shaders/shade.wgsl |
Applies lighting to computed colors. |
fidget-wgpu/src/voxel/effects/shaders/common.wgsl |
Defines packed voxel helpers. |
fidget-wgpu/src/voxel/effects/shaders/merge.wgsl |
Merges indexed voxel images. |
fidget-wgpu/src/voxel/effects/shaders/ssao.wgsl |
Computes GPU SSAO. |
fidget-wgpu/src/voxel/effects/shaders/blur.wgsl |
Blurs SSAO output. |
fidget-wgpu/src/pixel/mod.rs |
Updates shader helpers and tests. |
fidget-wgpu/src/lib.rs |
Adds color types and shared bytecode preparation. |
fidget-wgpu/Cargo.toml |
Adds layout-test dependency. |
fidget-core/src/var/mod.rs |
Adds Debug to VarMap. |
fidget-bytecode/src/lib.rs |
Adds bytecode input remapping. |
demos/cli/src/main.rs |
Updates effects API usage. |
Cargo.lock |
Records the new dependency. |
Review details
Suppressed comments (4)
fidget-wgpu/src/voxel/effects/shaders/shade.wgsl:71
- The grayscale branch no longer ORs in
alpha, so every non-color render (including the CLI caller passingfalse) produces pixels with alpha 0 instead of the opaque pixels emitted before this change. Preserve the alpha byte in this branch as well.
fidget-wgpu/src/voxel/effects/mod.rs:686 - The public constructor accepts color expressions containing
Var::V, and the internal evaluator supportsShapeVars, but this only public submission path always supplies an empty map. Such expressions therefore always fail withMissingVarand callers have no way to provide the required values. Expose asubmit_color_with_varspath (as the pixel and voxel contexts do) or acceptvarshere.
This issue also appears in the following locations of the same file:
- line 1100
- line 1120
fidget-wgpu/src/voxel/effects/mod.rs:1120
- This unconditional
println!makes a library render operation write to the application's stdout on every color pass, which can corrupt CLI output and add per-frame noise. Remove it (or use opt-in tracing if diagnostics are needed).
fidget-wgpu/src/voxel/effects/mod.rs:1100 ColorError::BadShapeCountis never produced:MergeBuffers::image_countis recorded but never compared with the number of color entries. A mismatch therefore reaches the shader and either paints indexed pixels red or silently leaves extra colors unused instead of returning the documented error. Store the color count inShapeColorBuffersand validate it here before creating bind groups.
- Files reviewed: 10/15 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+2828
to
+2832
| .color_buffers(&[ShapeColor::Rgb { | ||
| r: VmShape::from(Tree::constant(0.0)), | ||
| g: VmShape::from(Tree::constant(1.0)), | ||
| b: VmShape::from(Tree::constant(0.25)), | ||
| }]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a WebGPU compute pass which evaluates per-pixel color expressions.