Skip to content

Conversation

@aleksanderkatan
Copy link
Contributor

@aleksanderkatan aleksanderkatan commented Dec 8, 2025

I have trouble optimizing this.
It may be due to the fact that we call castInterval upwards of 14 billion times a frame (given a resolution of 1000x1000).

image

I tried to optimize this by prerendering the sdfs into a texture so that each pixel averages only one getScene call 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:

@aleksanderkatan aleksanderkatan linked an issue Dec 8, 2025 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Dec 10, 2025

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/typegpu@ac95f55c6066bc8691b1604cc468839362247d3b
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@ac95f55c6066bc8691b1604cc468839362247d3b
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@ac95f55c6066bc8691b1604cc468839362247d3b

benchmark
view benchmark

commit
view commit

@aleksanderkatan aleksanderkatan changed the title docs: Volumetric gi example docs: Volumetric Global Illumination (Radiance Cascade) example Dec 11, 2025
Copy link

Copilot AI left a 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.

@aleksanderkatan aleksanderkatan marked this pull request as ready for review December 11, 2025 16:16
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.

docs: Volumetric global illumination example

2 participants