Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

How does the Radiance treat path termination when pathtracing diffuse reflections?

asked 2021-06-14 13:34:30 -0500

JChen1234's avatar

updated 2021-06-22 10:24:44 -0500

In Chap. 12 of Rendering with Radiance by @GregWard and Shakespeare, it is reported that a constant ambient approximation is used when the -ab number of bounces is reached in the pathtracing process.

Is this still the way Radiance deals with path termination now?

In the source code file ambient.c line 360-380, I do see some code that does constant ambient approximation. However, in the raytrace.c line 119-134, I see that the unbiased Russian Roulette is used.

I would like to confirm that for the functions like rcontrib and rfluxmtx, we are actually using Russian Roulette algorithm, right? In this case, the result should be unbiased no matter what -ab, -av or -aw parameter is given, right? In In Chap. 6.4.2 of Rendering with Radiance, the author "expect(s) the prediction for -ab 5 to be greater than those for -ab 1"; this in theory should not be the case for the tracer with Russian Roulette, right?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-14 13:55:11 -0500

updated 2021-06-14 13:57:24 -0500

It's complicated. The -ab parameter sets a hard limit on the number of indirect diffuse bounces, so you should set this to some large number if you are concerned. That said, rcontrib (and rfluxmtx) do use Russian-roulette sampling by default (-lr -10 from "rcontrib -defaults"), and follow a path-tracing protocol when it comes to the indirect diffuse component. If you set -ab 10, then Russian-roulette will decide ray termination in most cases in an unbiased fashion. The -lw setting together with -ad will decide how many ray paths are followed, and lw*ld should be > 1.

Since rcontrib and Russian-roulette sampling are more recent additions, Rendering with Radiance does not cover them.

Regarding the -av setting, this is used as a "remainder" in the infinite series once the finite number of terms corresponding to your -ab setting has been computed. It should roughly equal the average radiance in your scene in any direction, but can be safely set to "0 0 0" for unknown conditions.

I hope this helps

edit flag offensive delete link more


Thank you. It now makes sense as -ab is a hard limit on the diffusive bounces. That's probably the reason why setting -ab to higher numbers increases the result up to a point.

You mentioned -lr parameter, which limits the number of reflections even with Russian Rolette. Does this parameter have the same effect as the -ab parameter?

JChen1234's avatar JChen1234  ( 2021-06-14 20:51:35 -0500 )edit

Yes, you should set -ab N -lr -N if you want to increase the maximum number of reflections, which can be as high as you like. (It stops making a difference after 10 or so in most scenes, which is why it is set to that.)

GregWard's avatar GregWard  ( 2021-06-14 21:32:29 -0500 )edit

Hi Greg. For a negative -lr value the man page says "this sets the upper limit of reflections past which Russian roulette will be used".. "past which" , so does it mean that you could get bounces more than N based on RR? Looking at the code raytrace.c line 122, it doesn't suggest that: it terminates the ray after N bounces. Could you shed some light on this please. thank you.

ali fatoor's avatar ali fatoor  ( 2021-10-19 09:18:15 -0500 )edit

The code is always the ultimate reference, and your understanding of it is correct. It is the man page you are using that is incorrect. The latest man page does not have this error, which makes me wonder which one you are using? Please go to the official site at for reference.

GregWard's avatar GregWard  ( 2021-10-19 10:32:29 -0500 )edit

Thank you Greg, that explained. I used this rtrace link which came up first on my google search. So does it mean that with a negative value it applies RR from the first bounce?

ali fatoor's avatar ali fatoor  ( 2021-10-19 11:59:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops


Question Tools

1 follower


Asked: 2021-06-14 13:34:30 -0500

Seen: 155 times

Last updated: Jun 14 '21