Cutting down render times…
First the bad news, I have noticed that sim_physics volumetrics perform a full integration regarding the optical tickness of the object. Here is an example of the current drawback: Given a cube of very dense smoke aligned to the camera: let’s assume that it will take a render time T: now if you scale 10 times the edges perpendicular to the viewer then render time will take 10*T with no significant difference from the previous render!
That could be perfect for truly realistic renderers where every detail matter, but it also eats a lot of render time, that´s why every volumetric render engine out there implement an optimized algorithm called Early Ray Termination (ERT).
This algorithm basically stops integrating along a ray when total opacity is near the maximum value, so voxel samples behind will not contribute at all to the image pixel. In my thesis build since I accumulate alpha values from the beginning, I make the raymarch (integration) along the ray stop as soon as accumulated alpha reaches the value 1.0 (= opacity): As a result render times were incredible shorted for very dense volumetrics (denser smokes,rocks,and other special effects)
However, my build lacks optimization for empty volumes contrary to Matt Ebb’s one (“sim_physics” branch), which shines on it. Consequently, I have taken some time to mix the strength of both builds and now are the good news🙂
Since sim_physics implementations are based on physics terms the most direct mapping to final opacity seems to be the total transmittance, so I only will need to check it as an additional condition to keep the volumetric integration loop, and that´s basically the modification🙂, simple but powerful and allow a new range of effects for sim_physics and at the same time cut down render times for thick volumetrics.
Here I show you some results :
No ERT: render time = 21s 93
ERT: 9s 39
The new Parametter added is Thickness in range from 0 to 3.0, 0 performs the full volumetric integration for every ray as is now sim_physics, while other value stops the integration when the accumulated transmitance reach the value specified for the user.
No ERT: 21s 38
ERT, thickness=0.1 : 16s 29
ERT, thickness=0.2 : 14s 38
With big volumes and denser smokes the render time gained is more noticed🙂
No ERT: 1s 52 ERT, thickness=0.2 : 0s 52
Off course, the final quality is up to the user, and does not only depend on the thickness parameter, because there will always be a need for either very transparent volumetrics or very opacy ones.
Volumetrics with lot of empty areas will gain little with ERT but they are already optimized thanks to your build so now we could have best of both builds!
Also, now are possible new range of volumetric effects that sim_physiscs have lacked since it was focused on thinnier smokes, take a look:
No ERT: 5s 25
ERT, thickness=0.1 : 4s47
ERT,thickness=0.3: 3s 80 ERT, thickness=0.6 : 2s 86
Now are achieved a desired effect, the volumetric blobs seems denser enough to totally occlude anything behind it and that is in control of the user, previously with combinations of density scale,absorption,emission and so this effect where very difficult if not impossible to achieve, volumetrics keep looking too transparent and that was due to the full ray integration.
Here is the very interesting effect with little render time🙂
ERT, thickness=2.0: 2s 59
and finally some screen captures..