# Illumination model used in the “Raytracer in a weekend” series

I was going through the raytracer in a weekend book by Peter Shirley and the subsequent book raytracing the next week and I couldn't make out what was the illumination model that was being used here.

all the previous raytracing samples that I have come across use the Phong shading model in which

• For a diffuse surface, a shadow ray is generated towards all the light sources and the final color is calculated based on the diffuse color and the non-occluded light intensities
• For reflective materials and dielectrics, reflective and refractive rays are generated which are then recursively projected into the scene

The method used in the book (very briefly) is as follows (Please do correct me if my understanding is wrong in any way)

• For diffuse objects, a ray is traced recursively in a random direction biased towards the normal at the hitpoint and the color from the resulting ray is multiplied with the current object's albedo to give the final color
• For reflective and dielectrics, rays are cast using the law of reflection and the Snell's law respectively.
• Lights also scatter rays and also add their emitted parts.

The major differences I see in this approach are

• We do not directly sample the light sources.
• Diffuse items also reflect rays (for inter-diffuse reflections)

What exactly is the illumination model used in this approach? and why does this approach seem so simple and yet produces pretty good results?

Sorry if I missed something, I am relatively new to raytracing

• Seems to me he is is simulating global Illumination, which is basically indirect lightning due to light coming at surface after being reflected from other surfaces. So yeah, we don't just shoot rays from intersection point (IP) to light directly, instead we shoot random rays from IP in order to simulate that indirect lighting coming from different surfaces. – gallickgunner Jun 10 '18 at 13:45
• These are two different illumination model: Local vs Global illumination. Global illumination considers all the light paths and its interaction with surfaces. A diffuse surface for example does not only receive light from a light source but scatters light in multiple direction around its local hemisphere which needs to be recursively traced. The later approach is very costly and needs statistical approach(monte carlo integration) to solve. – ali Jun 13 '18 at 8:31

It’s a “naive” Monte Carlo sampler so it’s too dumb to send rays toward lights— it shotguns. But the light is just a hemisphere (like a cloudy day) so you don’t get punished with too much noise. Cloudy days look pretty good in real life. But if you try to add a small light it will work but get very very noisy. The third book in that series uses one method to address this (basically sending more rate where lights are rather than shadow rays per se)

I have not read the links but you remember that in the classical ray tracing ,namely Whitted rayTracing, a single ray is traced from viewpoint to each pixel and alone if a complete diffusive surface is intercepted the reflected ray (secundary ray) isn't calculated. Practically the contribution of indirect illumination on the specular diffusive surface is multiplied for $K_s$ i.e. the specularity coefficient of material and if diffusive coefficient $K_d$ is very hight $K_s$ will be very low and thus the reflective ray in that point isn't traced thus there will be a threashold to stop recursion. Furthermore the recursion tree is a binary tree because is launched between secundary ray the rifraction ray also.

In this method there is subsampling namely aliasing: in the real case more that a ray determines the color of a pixel and in Witthed is like to use a sample(a single ray) for each pixel. Thus we can launch more that a ray for each pixel but not one ray for each equally divided space of the pixel (otherwise supersampling namely aliasing to a bigger frequency) but the rays are sent in a stochastic way like this they will hit the areas where the color variation is higher (these areas cause aliasing). The Witthed ray Tracing here is rephrased following Kajiha equation of rendering that bring to solve an integral of the BRDF with Montecarlo method choising with importance the samples to estimate the integral using the BRDF or its estime like a probability distribution. Following these sthocatic approaches there are distributed ray tracing and path ray tracing for instance.