Skip to content

WebGPUPathTracer: Use half float storage target w/ Kahan summation#749

Closed
gkjohnson wants to merge 18 commits intowebgpu-pathtracerfrom
webgpu/halffloat
Closed

WebGPUPathTracer: Use half float storage target w/ Kahan summation#749
gkjohnson wants to merge 18 commits intowebgpu-pathtracerfrom
webgpu/halffloat

Conversation

@gkjohnson
Copy link
Copy Markdown
Owner

Relies on #748
Related to #133

  • Changes the output buffers to use HalfFloatType to ensure support on mobile and WebGPU in general (float type targets are not guaranteed).
  • Half float targets are also always filterable.
  • Use Kahan summation to avoid accumulation of error:
    • Quantize the blended color to F16
    • Calculate the delta between the F16 and F32 value
    • Pack the delta into an 8 bit value for each channel
    • Write those 8 bit values into a read/write r32 texture via bitwise ops
    • Read and unpack the delta on subsequent blend to prevent error accumulation
  • Add an ssl option to the start command to allow for testing on mobile (WebGPU requires https) - run npm start -- --mode=ssl --host
  • Adjust the ProceduralEquirectTexture to use HalfFloatType to guarantee its filterable.

With these changes both the wavefront and megakernel path tracers work on my phone 🎉

image

cc @TheBlek

@gkjohnson gkjohnson added this to the v0.0.25 milestone Mar 11, 2026
@gkjohnson
Copy link
Copy Markdown
Owner Author

gkjohnson commented Mar 11, 2026

I'm a bit worried about precision loss on this - it looks okay in this simple scene and simple BRDF but I expect with enough samples and with high enough values we'd start to see some degradation. The primary issue is that float textures are not guaranteed to be filterable but they do seem to always be available in WebGPU (outside of compatibility mode). It may be best to implement custom filtering when writing to the canvas if filtering isn't available.

@gkjohnson
Copy link
Copy Markdown
Owner Author

Closing in favor of #750

@gkjohnson gkjohnson closed this Apr 27, 2026
@gkjohnson gkjohnson deleted the webgpu/halffloat branch April 27, 2026 07:25
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