Shadow Ray Manipulation
Suppose your scene is set inside a cave, and you want ambient light infused throughout your cave. An ideal solution might be to place an environment light outside of the cave and “ignore” your cave for the purposes of shadowing. There are, in fact, a number of reasons you might wish to ignore occluding geometry: to bring more light in, to avoid self-shadowing, to prevent non-hero objects from casting distracting shadows, and so on.
MoonRay provides a number of different controls that allow us to ignore occluding objects:
What are shadow rays? Permalink to What are shadow rays?
At each shading point in the scene, we must determine whether (and how much) the point is in shadow. The way we measure this is by shooting a shadow ray toward the point we’ve sampled on the light. If our shadow ray intersects with some geometry in the scene before it reaches the light, it’s considered to be in shadow, and the radiance we might have added from the light is discarded. We shoot as many shadow rays as there are light samples.

Each of our shadow ray settings allow us to ignore shadow-casting objects by shortening the shadow rays, ensuring that they do not find intersections with geometry within a certain distance. While the mechanism is similar for each attribute, they differ in the following ways:
- They either move the start or end of the shadow ray
- They measure distance from either the shading point or the light intersection
- They are defined either on a per-geometry basis or a per-light basis
Shadow Ray Epsilon Permalink to Shadow Ray Epsilon
The shadow_ray_epsilon attribute effectively establishes a radius around the shading point within which no objects can cast shadows. It does this by moving the origin of the shadow ray the specified distance away from the shading point, preventing it from finding the nearby intersections.
Moves the start of the shadow ray | Measures distance from the shading point | Defined on the geometry |

Min Shadow Distance Permalink to Min Shadow Distance
The min_shadow_distance attribute is identical to shadow_ray_epsilon, except that it applies to a specific light instead of a geometry.
Moves the start of the shadow ray | Measures distance from the shading point | Defined on the light |

Shadow Ray Epsilon vs. Min Shadow Distance Permalink to Shadow Ray Epsilon vs. Min Shadow Distance
shadow ray epsilon | Moves the start of the shadow ray | Measures distance from the shading point | Defined on the geometry |
min shadow distance | Moves the start of the shadow ray | Measures distance from the shading point | Defined on the light |
Max Shadow Distance Permalink to Max Shadow Distance
The max_shadow_distance attribute establishes a radius around the shading point outside of which objects don’t cast shadows. It does this by moving the end of any shadow ray the specified distance away from the shading point.
Moves the end of the shadow ray | Measures distance from the shading point | Defined on the light |

Min vs Max Shadow Distance Permalink to Min vs Max Shadow Distance
min_shadow_distance | Moves the start of the shadow ray | Measures distance from the shading point | Defined on the light |
max shadow distance | Moves the end of the shadow ray | Measures distance from the shading point | Defined on the light |
Clear Radius Permalink to Clear Radius
The clear_radius attribute establishes a radius around the light within which objects cannot cast shadows. It does this by moving the end of the shadow ray the specified distance away from the light.
Moves the end of the shadow ray | Measures distance from the light intersection | Defined on the light |

Combining All Attributes Permalink to Combining All Attributes
How do all of these attributes work together? Well, there are a few different scenarios:
- Both attributes move the origin of the shadow ray (shadow_ray_epsilon, min_shadow_distance). We take the maximum distance between the two.

- Both attributes move the end of the shadow ray (max_shadow_distance, clear_radius). We take the minimum distance between the two.

- One attribute moves the origin of the shadow ray, and one moves the end. We move both the start and end of the ray accordingly. If either the start or the end of the ray overlaps the other, we end up with a shadow ray with zero length (since we can’t have negative length), so we ignore all occluders along the ray.


Quick Reference Permalink to Quick Reference
Shadow Ray Epsilon | Min Shadow Distance | Max Shadow Distance | Clear Radius |
---|---|---|---|
Moves the start of the shadow ray | Moves the start of the shadow ray | Moves the end of the shadow ray | Moves the end of the shadow ray |
Measures distance from the shading point | Measures distance from the shading point | Measures distance from the shading point | Measures distance from the light intersection |
Defined on the geometry | Defined on the light | Defined on the light | Defined on the light |