-
-
Notifications
You must be signed in to change notification settings - Fork 45
docs: Volumetric Global Illumination (Radiance Cascade) example #1962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a new volumetric radiance cascades example to the rendering category, implementing a port of the "2D Volumetric Radiance Cascades" shader from Shadertoy. The example demonstrates an advanced global illumination technique using radiance cascades to compute volumetric lighting in 2D with fully converged (noise-free) radiance. The implementation includes scene rendering with signed distance functions, the core radiance cascade algorithm with bilinear interpolation, and post-processing with ACES tonemapping and gamma correction.
Key changes:
- Adds complete volumetric radiance cascades implementation with configurable cascades, quality settings, and multiple demo scenes (Shadertoy, Hearts, Dots)
- Introduces
mockMathRandom()utility for deterministic testing of examples using randomness - Includes comprehensive test coverage with inline shader snapshot validation
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/typegpu/tests/examples/utils/commonMocks.ts |
Adds mockMathRandom() helper to ensure deterministic test behavior for examples using random values |
packages/typegpu/tests/examples/individual/volumetric-radiance-cascades.test.ts |
Complete test suite with shader code snapshot validation for the new example |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/meta.json |
Example metadata configuration marking it as experimental with relevant tags |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/index.ts |
Main entry point orchestrating the three-pipeline rendering system (prerender, cascade merge, display) |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/index.html |
HTML template with attribution to the original Shadertoy implementation |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/castAndMerge.ts |
Core radiance cascades algorithm with extensive documentation and bilinear interpolation |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/scenes.ts |
Scene definitions using SDFs (circles, hearts) with animated elements |
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/image.ts |
Post-processing functions for ACES tonemapping and sRGB gamma correction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/castAndMerge.ts
Show resolved
Hide resolved
apps/typegpu-docs/src/examples/rendering/volumetric-radiance-cascades/index.ts
Outdated
Show resolved
Hide resolved
…ascades/index.ts Co-authored-by: Copilot <[email protected]>
I have trouble optimizing this.
It may be due to the fact that we call
castIntervalupwards of 14 billion times a frame (given a resolution of 1000x1000).I tried to optimize this by prerendering the sdfs into a texture so that each pixel averages only one
getScenecall but it didn't help much. I also added a slider that reduces the resolution of the canvas.I still don't get the radiance cascade algorithm, but I'm starting to suspect that it isn't implemented correctly (either the OG example, or a mistake in the port).
I suggest that we leave this as a DEV example, and try to optimize this later.
Some links: