The solution is to apply a "smoothing" constant having a value between 0.0 to 1.0. This number is simply scales the distance estimated sampled at every step, such that the ray will only march a certain % of the distance. So no smoothing would be 1.0, stepping the whole distance towards the scene.
This is a balance between quality and performance. Smoothing eliminates the rippling distortion effect. However, now that we're taking a non 100% of the distance sampled, we need to take more steps in order to reach the scene.
The suggested smoothing level is 0.5, but I'm afraid performance would take a hit since now I'll have to take many more steps in order to render the edge details. A good number that I empirically came up with is 0.75, meaning the ray march would only march 75% of the distance closest to the scene.
Below are examples:
The twisted cube. Smoothing at 0.75.
Some minor rippling effect still visible at lower left corner, but is much better.
The Julia quaternion fractal. Smoothing 0.5.
Now smooth everywhere compared to before where there were gaps in the surface.
Would you care to open source your examples? :)
ReplyDeleteThe code is hosted publicly here:
ReplyDeletehttps://github.com/prutsdomj/WebGL-RayMarch