Ray Recursion Limit, on the Rendering tab of the Render Options panel, is used when rendering Ray Traced Reflections, Refractions, and Transparency.
In the case of Reflections, it determines how many times each light ray bounces, before LightWave simply returns the color of the Backdrop pixels (or the Spherical Reflection Map, if you are using one,) instead of more reflections.
In the case of Refractions and Transparency, it determines how many surfaces the ray travels through before it stops, and simply fills in with the Backdrop color.
LightWave allows you to choose a Ray Recursion Limit between 1 and 24. (You can pick zero, too; but you'll get a warning that this effectively disables ray tracing, which it does. So does 1, for anything except Ray Trace Shadows.)
By default, the value is 16; but that's not necessarily the best value for the scene that you are working on. Depending on the surfaces and objects in your scene, adjusting this value to the lowest necessary (or acceptable) number can make a real difference in render time.
Even in simple scenes, setting this value to the minimum necessary can shave fractions of seconds off each frame; and those fractions add up, as we all know.
The trick is to find out what the minimum necessary is.
If the only Ray Tracing you are using is Shadows, you might want to time a frame to see whether it's faster to reduce the setting to 1, or simply to leave it alone. Sometimes it's faster one way, and sometimes the other.
For example, this scene, using only Ray Trace Shadows, actually took almost a second longer to render with a Ray Recursion Limit of 1 than with the default. (Rendered at 640x480, Low AA.)
This scene, on the other hand, using essentially the same settings (480x640, Low AA,) took a bit more than a second less to render using an RRL of 1. So the moral of the story is; if it's important to save every second, test a frame.
Ray Trace Transparency is only needed to see volumetric effects through transparent surfaces. When you're using it, it's essential that you have enough Ray Recursions to see through all the levels of transparency between the camera and the object. To do that, count one for each transparent surface, and add one. So, in this example, you would need a Ray Recursion Limit of 3; one for each window poly between the camera and the effect, plus one.
Let's take a look at the same window being rendered. In this instance, Ray Trace Transparency has been disabled. As you can see, the tree and sky are visible through the window panes, but the Volumetric effect doesn't show up at all.
Here, Ray Trace Transparency has been enabled, but the Ray Recursion Limit is only 1. That's not enough to get through anything, so, as you can see, the window panes are completely opaque. (The black is the backdrop color. If I'd used a purple backdrop, the panes would be purple.)
Increasing the RRL to 2 allows the rays to penetrate a single layer of the glass, as shown at the top and bottom, where there's no overlap between the two window sashes. (You may also notice that the top window is now visible behind the one on the bottom, although that second layer of glass stops the rays from getting outside.)
It takes an RRL of 3, as noted in the "counting" image above, to allow the rays to penetrate the area where the windows overlap, so you can see the entire volumetric ray clearly.
As the Ray Recursion Limit was increased in each of the instances noted above, the render time also increased, because LightWave was adding information to the image.
With Ray Trace Transparency disabled, it took 3m 36.3s to render at 480x640, with Low antialiasing. With an RRL of 1, it took 3m 13.4s; a decrease in the render time, since less information was being added to the image. When the RRL was increased to 2, the render time jumped to 5m 24.1s. At 3 it went to 9m 15.3s.
As you know, at that level the rays were getting through all the window panes, and no further information was being added to the image. However, when the RRL was increased to 16 (the default, if you recall,) the render time increased by 5 seconds, going to 9m 20.3s. Over the course of an animation, 5 seconds per frame can make a difference. So it's worth counting the layers, and not using more than you need.
If you want to test for the correct number, it's easy. Use the basic formula (surfaces + 1) and then decrease the number by one. If you can see through all of it, you miscounted somewhere. Keep decreasing until you can't, then increase by one again.
(By the way, in the images above, that nifty wallpaper is courtesy of Eisenhart Wallcovering Co., French Country Collection. It's important to give credit to your sources, and honor their copyrights, after all.)
When using Ray Trace Refraction, once again, you can simply count the number of transparent polys that face the camera, add one, and use that number for your Ray Recursion Limit. Don't forget to count both the surface polys, and the air polys that are used to change the Refraction Index back to 1.0, as seen below.
Let's take a look at that in action.
This render uses a Ray Recursion Limit of 5, as specified in the formula. One for each layer of glass, air or water in the tumblers or pitcher, plus one. But take a look at the image.
As you can see, this value got through the glass; but not the transparency behind the glass. You can't see through the window where it's behind the pitcher, nor can you see through the second tumbler when the first is in front of it. (Run your mouse over the image for a close-up, or click on it to see a larger view.)
Obviously, a higher Ray Recursion Limit is called for. So, adding the window pane to the pitcher gets 5 levels of transparency in front of the camera. Adding the four levels in the second tumbler gives us 8 levels (4 for each one.) That's higher, of course, so we'll use that one, plus one gives us a minimum RRL of 9. So let's try that.
Much better! Now all the transparent surfaces are actually transparent. The render times? The first one (RRL 5) took 4m 32.3s. The second (RRL 9) took 5m 3.9s. More time, but also more information in the image.
Increasing the Ray Recursion Limit in this instance will continue to add information, because of the shape of the tumblers and pitcher. (The curvature on the lip of a glass adds more layers of transparency for a ray to get through, while a flat pane, like the window, does not.)
Rendering again, with the default RRL of 16, does add a tiny bit more information; as seen below. But it also adds to the render time. In this example, the higher RRL takes 5m 19.4s to render. A difference of 15.5 seconds. Which doesn't sound like much, until you realize that's a bit more than a quarter of an hour for every 60 frames you render.
Can you see the difference in those two renders? Look at the edges of the glass; that's the only place it's visible. Still having a hard time? Okay, try this. Below is a section of the above RRL 9 image, seen at 200%. Run your mouse over the image to see the same section (at the same magnification) from the RRL 16 image.
Is it worth the time difference? Only you can answer that. Like everything else in 3D, it's a trade-off. It depends on how much time you have, who your target audience is, and what they expect.
Testing for the best Ray Recursion Limit for Refraction is a simple matter of counting, using the formula, and then rendering. If what you see is acceptable, you're golden. If it's not, bump up the RRL until it is.
Ray Trace Reflections follow the same formula. Just count the number of reflective surfaces that are close enough to each other to form a reflection, and add one.
So, for this aluminum soda glass from the '50s sitting on a reflective table, you'd have 2 surfaces, plus one, for a Ray Recursion Limit of 3
Let's take a look at how that works out. First, a render without Ray Trace Reflections at all. The only reflections on the glass at this point come from a Spherical Reflection Environment. As expected, you can't see any reflections of the glass in the table, and none of the table is reflected in the glass.
Increase the Ray Recursion Limit to 2, and you start to see real reflections. The table is visible reflected onto the glass, and vice versa.
However, our formula says that the RRL ought to be 3, so let's try that.
Sure enough, that adds a level of reflection. Look carefully at the reflection of the glass in the table, and you'll notice that you see more than the glass. That reflection now contains the reflection of the table, as well. Another bounce, another layer of reflections.
And, at this point, that's all that there are. You can increase the RRL to 16, and in this case you won't see any more than you see here. But you will increase the render time; from 12.3 seconds without any reflections, to 19 seconds with an RRL of 2, to 20.1 with an RRL of 3 up to 24.5 with an RRL of 16. Considering how very simple this scene is, an increase of 4.4 seconds is a fairly large jump, for absolutely no increase in quality in this case.
What happens if we add another surface? Let's take a look. We'll put a magenta aluminum soda glass into the picture, to go with the green one that's already there, and look at it with a RRL of 3.
Now, let's try increasing the RRL to 4, which should be the correct number, according to our formula.
See the difference? You don't? Well, it's a web page, and the images are small. Let's try again, with another one of the 200% comparative enlargements. This is the RRL of 3. Mouse over it to see RRL 4. Watch the left side.
That tiny difference costs exactly 1 second of render time. (From 29.6 to 30.6 seconds.) Taking the Ray Recursion Limit up to 16 costs another 4.3 seconds (34.9 seconds) but there's no discernible difference at all in the render, at this size and AA level. (There probably is some, inside the glass itself, but it falls within a pixel, so it doesn't show up.)
So, once again, it's a trade-off; Detail vs Render Time, as always. But now you know where you can shave seconds off each frame, and not lose any detail.
And now, when you hear someone tell you to "reduce the Ray Recursion Limit to the lowest necessary," you know what they're talking about, and you know how to figure it out!
If you want to play with the soda glasses or water pitcher, so you can try some of your own tests, and run your own experiments, you can download them here. Have fun!