Skip to main content

trace

Function trace 

Source
pub fn trace(
    ray: Ray,
    occluders: &[Occluder],
    lights: &LightingUniforms,
    max_bounces: u32,
) -> Vector3D
Expand description

Recursively traces a ray through the scene and returns the final shaded color.

The function first finds the closest hit via closest_hit. On a miss it returns the ambient color. On a hit it evaluates the surface material with LightingUniforms::shade and, when the hit material has a non-zero specular component, recurses with a reflected ray up to max_bounces times (decrementing the ray’s depth field).

§Arguments

  • Ray - The ray to trace.
  • &[Occluder] - All occluding surfaces in the scene.
  • &LightingUniforms - Lighting parameters used during shading.
  • u32 - The maximum number of bounces allowed for this ray.

§Returns

  • Vector3D - The final traced color.