# Efficient empty volume rendering in Cycles

Suppose I am rendering a smoking torus from above in Cycles:

(at laughably bad resolution, of course, but that's not the point)

Cycles spends a lot of time rendering the empty space, even though the density is 0 (and therefore, the volume should have no effect on light). I don't quite know why Cycles has to think so much.

In fact, the render times can be almost halved (from 11 min to 6 min) by using an old BI trick and masking empty parts of the volume with a shadeless object (which can be made here).

This is fine for simple test renders, but now I'd like to make actual scenes with smoke and fire in them, and obviously my little masking trick won't work because there are objects behind the smoke that can't be masked. (Also, shrinking the domain is not an option)

How can I optimize scenes with large empty volumetric sections?

• Could you not group the smoke and mask on a separate render layer? – Todd McIntosh Jun 30 '15 at 19:11
• @ToddMcIntosh I can't. :( I'm rendering fire, and I need the fire to actually light the scene. – PythonNut Jun 30 '15 at 19:14
• Could you fake the bounce lighting with lamps with animated emission? – Todd McIntosh Jun 30 '15 at 19:15
• @ToddMcIntosh sorry, nope. I probably could if the scene weren't so specific, but the fire is right up against a plane, and you can clearly see its shape... I'd rather not approximate if I can help it. – PythonNut Jun 30 '15 at 19:17

It's actually quite similar in Cycles and seems to speed up renderings as well (which indicates there is still room for optimization in Cycles volume rendering).

So with a basic setup:

You get result (~16 seconds):

Now add a Shader Mix Node and use Density as a Mix factor:

With current Cycles algorithms you can leave the second slot unconnected - it just tells Cycles to compute volume rays for areas that are masked by density with a value greater than 0.5 (screen shows the reverse of that, but it's the same if you connect Volume shader in second slot and use converter math node 'Greather than', which would be more intuitive, I guess).

Now the result of this little tweak: Time almost halves! But there are very crisp edges - you can tweak that with changing the converter math node value to a very low number (which would tell cycles to leave out only area with density values close to zero:

And the result:

Still reasonable improvement over the original render time and nearly the same visual effect.

• I don't know who you are, or what your credentials you have. I don't know whether you're a good person or bad. But I do know that you are a GOD DAM HERO Kilbee. This little trick has just knocked 8 minutes off each frame on a 200 frame explosion. I seriously Effing love you !! – Rich Dec 5 '16 at 1:43