5.3.3. Recursion Limit

The recursion limit is the maximum number of times that a ray can “bounce” within the scene when rendering a frame. The higher the recursion limit is, the more accurate the scene appears, due to the higher numbers of reflections and refractions. However, a deeper recursion in highly reflective/specular scenes may stress interactivity as many secondary rays may be required for computing reflection and refraction effects. The recursion limit can be used to reduce the number of rays shot – possibly only during user interaction.

  • Reflection (ray reflected by a shape) and shadowing are enabled when the recursion limit is at least 2.

  • Refraction (ray traversing a shape) is enabled when the recursion limit is at least 3.

The recursion limit is set with the SoPreferences SoPreferences SoPreferences DIRECTVIZ_RECURSION_LIMIT parameter or SoDirectVizManager SoDirectVizManager SoDirectVizManager recursionLimit field.

Recursion can be disabled – forcing recursion limit to 1 – when in subsampling mode (i.e., during interaction) by setting the SoPreferences SoPreferences SoPreferences DIRECTVIZ_SUB_RECURSION parameter or SoDirectVizManager SoDirectVizManager SoDirectVizManager subRecursion field to 0. This can be changed interactively with the check button of the recursion limit item in the DirectViz control dialog.

Recursion limit 1, 2, 6

Figure 5.8. Recursion limit 1, 2, 6