MilchRatchet / Luminary

CUDA based Pathtracing Offline and Realtime Renderer
MIT License
30 stars 1 forks source link

Volume rework #85

Closed MilchRatchet closed 1 year ago

MilchRatchet commented 1 year ago

This PR reworks the fog and underwater volumetrics. The new system actually looks great and I am really happy about it. The most significant limitation right now is that the system only supports homogenous media that is bound by disk-box. However, anything else would quickly become infeasible for this project.

The ocean surface also saw an overhaul, however, I am not super happy about it. Overall, the ocean now looks a little bit nicer and fine detail is now more accurate. However, some more artifacts pop up now and performance is also worse. Here the main problem is a robust ray intersection test. Essentially we want to find the left most root of a Lipschitz continuous function over a bounded interval. I tried a few things and a ray marcher whose SDF is based on the Lipschitz constant of the height function somewhat works albeit with some issues and poor performance. I will have to look into literature for that a bit to see if anyone came up with solutions for such a problem yet, I am really no expert in that area.

I also fixed some crashes. Currently, only one known crash is remaining, one that is happening on CPU side before any frame is actually rendered. However, it rarely happens and I couldn't track it yet.

The volumetrics also introduced a lot of fireflies. There is a new paper "Once-more scattered next event estimation for volume rendering" from last year that kind of claims to address this, however, this will be a topic for another day. For now, I implemented a hard firefly rejection method which pretty much eliminates all fireflies at the cost of having a dark flicker during the second frame and some small linearly decreasing bias. Improving this method could also be a topic for another day.