gkjohnson / three-gpu-pathtracer

Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.
https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html
MIT License
1.38k stars 133 forks source link

Investigate floating point averaging bias #133

Open gkjohnson opened 2 years ago

gkjohnson commented 2 years ago

https://twitter.com/BenHouston3D/status/1521962488807444481?t=gOGmOLpXPF55D4ihTdc9Ig&s=19

See banding in BG gradients

munrocket commented 2 years ago

If this is related to RGBA floating point packing, I think I have an idea how to solve this floating point precision issue.

gkjohnson commented 2 years ago

The issue is floating point precision and error resulting in artifacts like banding in gradients when performing math operations.

This three.js SSAA demo demonstrates the same kind of issue but with a fixed number of samples. The difference is that the pathtracer is performing a continuous average instead of fixed sample count.

richardassar commented 2 years ago

I think Kahan summation can help with this. The thought came to me the other day but is also noted here.