Part IA Michaelmas Term
Ray Tracing Algorithm
Basic Algorithm
The ray tracing algorithm traces rays from the eye through each pixel:
select an eye point and a screen plane
FOR every pixel in the screen plane
determine the ray from the eye through the pixel's centre
FOR each object in the scene
IF the object is intersected by the ray
IF the intersection is the closest (so far) to the eye
record intersection point and object
END IF
END IF
END FOR
calculate colour for the closest intersection point (if any)
END FOR
Time Complexity
Standard RGB Rendering
Assuming:
- pixels in the image
- objects in the scene
- light sources (Phong shading, no recursion)
Time complexity:
Breakdown:
- for finding ray-object intersections
- per intersection to compute shading (3 channels RGB)
Spectral Rendering (2025 Paper 3 Question 3(f))
To compute physically realistic colour, we simulate the full visible spectrum instead of just RGB:
- Divide the visible spectrum (380-730 nm) into discrete wavelength bins
- For each pixel, trace rays as usual but evaluate illumination at every wavelength
Time complexity:
The factor of replaces the constant 3 (RGB channels).
The Outer Loop
The pixel loop is the outermost loop:
- Each pixel produces one ray (or multiple for anti-aliasing)
- The intersection test loops over all objects
- The shading calculation loops over all lights
Optimisation Techniques
- Spatial data structures: BVH, octrees reduce intersection tests from to
- Early termination: Whitted-style recursion bounds
- Parallel processing: Pixels are independent, ideal for GPU
Summary
- Ray tracing traces one ray per pixel (or more for anti-aliasing)
- Time complexity is for basic Phong shading
- Spectral rendering adds a factor of for wavelength sampling
- Spatial data structures can dramatically improve performance
Past Paper Questions
2025 Paper 3 Question 3(b): Assuming a Phong shading model and no recursion, what is the time complexity of a ray tracing algorithm and why? [5 marks]
2025 Paper 3 Question 3(f): How would you compute an approximate full spectrum of colours instead of RGB values for each pixel? What is the time complexity? [4 marks]