Russian Roulette sampling

russian_roulette_arnold_maya

In this post we’ll have a look at some sampling technics that can dramatically speed up your render times without affecting image quality. Let’s explore the alSurface shader for Arnold, and the “magic” Russian Roulette check-box.

alSurface

The alSurface is a general-purpose shader (similar to the default aiStandard) from the alShaders library, that can create any material type (apart from hair and skin that have their own shader). It has two specular layers, so you can easily create layered reflections with no effort, and it ensures energie conservation.

alSurface layered model

So basically it has either a diffuse or a refractive/transmissive layer in the base and then you can add one or two specular layers on top ( a common roughness map in the first specular layer and a clear coat on top for instance).

This should cover most of the materials you will need, but you can always combine two alSurface with the alLayer node, or even with a more complex network with a layered texture and an aiUtility to receive the shading result.

Sample splitting

So diffuse, specular, refraction, IOR, we all know that from the aiStandard, and it works the same in the alSurface. So why would we use it instead of the “official” general-purpose Arnold shader?

Apart from the two specular layers, this shader has some optimizations that can dramatically decrease render times, specifically the Russian Roulette sampling, but how does it work?

russian roulette model

Let’s look at an example, rendering glass. In a “normal” approach the render engine will calculate at each intersection a unique ray for refraction and other for reflection, and “filter” the result using the index of refraction.

With Russian Roulette there is a random function in between that will either calculate the refraction or the reflection ray, according to the Fresnel function.

But if we’re using some “hacks” in between, what does it means in terms of image quality against the “real thing”?

russian roulette refraction glass maya

So, as you can see there is almost no difference between the aiStandard and the alSurface renders. In other hand, there is a big difference in render time, the alSurface is way faster for a given ray depth (10 in this example).

The render times are based on a 960×540 resolution with 5 AA samples, on a common desktop machine.

And if we populate the scene with some objects to reflect and refract we won’t notice much difference either, apart from the render times of course.

aiStandard render aiStandard | 17:44 min
alSurface render alSurface | 05:18 min

How do we turn it on?? Russian Roulette is on by default when you’re using the alSurface shader, see the image below.

russian roulette checkbox
cg generalist course therenderblog

Path termination

So what else can this Russian Roulette thing do for us? In a typical interior scene we would need many bounces to fill the scene with light, and some of those bounces, while they “travel” through the scene, become so dark that they won’t contribute much to the final result of the rendered image. So here the RR function will randomly choose to stop or continue to calculate those rays, which will result again in a very similar image but a dramatic speed increase.

For this scene I am using only an hdri light, wich has only a door and a window to let the light to fill the interior, which makes it really hard for a brute force engine like Arnold.

interior arnold maya aiStandard AA: 8 DIF: 6 DIF-DEPTH: 10 | aiStandard | 131:37 min
interior arnold maya alSurface AA: 8 DIF: 6 DIF-DEPTH: 10 | alSurface | 59:13 min

Conclusion

So definitely a great shader, and we only used some test scenes, imagine scaling this to a production scene, it could dramatically impact your render times. Although it’s not integrated in Arnold by default, the author received full support from solidangle while developing the shaders, and Russian Roulette technics have been heavily used in production.

A lot of potential here, if you want to know more about this subject in future posts, let me know in the comments below. And if you like our articles you will probably enjoy our course, the CG Generalist Course.

Thanks for reading.

  • Marco Di Monaco

    Hi, where I work we have version 1.1.2.1, and the binaries provided by anders dont seem to work (“unable to load procedure”). Have you tested them in an earlier version? Thanks.

  • Caio Pimentel

    Nice article!! I would appreciate if you took a new one about how to clean fireflys in Arnold, especially when using Alshaders with Russian Roulette! I’m not using AiStandard anymore now it’s only Alsurface all the way, and I think that is the trend to anyone who know the alshaders and had the opportunity to make some tests with it. Thanks!!

    • therenderblog

      Thanks Caio.

      Clamping the values to 10 or 20 for instance might help removing the fireflys, give it a try.

      Cheers

  • SebastianLauer

    Great Shaders indeed – thanks for the headsUp on RR, I wasn’t aware of that.

    Do you know if theres a way to adopt the custom fresnel curves workflow with this shader? In AiStandard I tend to disable the Fresnel tickbox and use custom curves with a samplerInfo on the SpecularColor instead, for example.
    With AlSurface I don’t see the possibility to turn off the built-in IOR !?

    • therenderblog

      I think you can set a big value in the IOR like 50/100 and then map the specular ammount with the remap nodes.

  • BabuS7

    shader is a cool, but where can i get some tutorials, or documentation about ?

    • therenderblog

      there aren’t many resources, but this is just a common shader like the aiStandard, you can follow the same “rules”, it’s designed to work like the standard arnold shader. There is no “official” docs as far as I know.

      https://bitbucket.org/anderslanglands/alshaders/wiki/Home

      • BabuS7

        thanx for fast replay, i have question about RR sample parameters and SSS, can u explain how to use they?

        • therenderblog

          I plan to do a follow up post about this shader, I will explore the sss parameters and share what i find.

          Cheers