Comments

I created two new scenes (one for Beers Law and the other for Spotlights) so combining the images from both the scenes into one and uploading. Whistle - Modified shadow attenuation to use Beer's Law. Added a new property _UseBeersLaw to the BlinnPhong.shader so as to toggle whether Beer's Law should be used or not. The default value for the property is set as 0 such that it doesn't interfere with the sample scenes for testing ray tracing. I created a new material with the _UseBeersLaw property set as 1 such that I could associate the material with the objects on which I wanted to use the property. Basically Beer's Law will be used for shadow attenuation whenever the property is set as 1. I also had to modify Material.cs to read the UseBeersLaw property from the material. Within RayTracer.cs, if the UseBeersLaw property is set, I am calculating the attenuation following Beers Law based on the distance the light travels inside the object and incorporating the same in the final shadow attenuation. I created a test scene BeersLaw to showcase this. The test scene has three spheres - one big and two small. The big one is using Beer's Law and the middle small one is also using Beer's Law. The shadow for the middle small one is comparatively darker than the other small one not using Beer's Law. Also the shadow for the bigger sphere is darker than the middle small sphere as light travels a longer distance in the bigger sphere. I have also checked in the corresponding rendered image. Bell - Implemented spotlights. Created a SpotLightObject.cs class similar to the already existing PointLightObject.cs class. Two additional properties which the SpotLightObject class contains over the PointLightObject class are the forward direction and spot angle for the spot light. Within RayTracer.cs, I am collecting all the spot lights and then looping over them while finding the direct component. I am calculating the angle between the vector pointing towards the intersection point from the spotlight position and the spotlight forward direction. If this angle is less than or equal to half of the spot angle of the spotlight, it means that the intersection point is within the spotlight area or coverage following which I proceed to find the direct component similar to how I am doing it for the point light. If the angle is greater than half of the spot angle of the spotlight, I am skipping calculating the direct component. I created a test scene Spotlights to showcase this. It is a copy of the BoxReflectShadow scene with the only difference being that the point light is replaced by the spotlight. The final rendered image is spherical or circular in nature as expected for a spotlight when compared with the output of the BoxReflectShadow scene which has a point light because of which the box is fully rendered. I have also checked in the corresponding rendered image.

Raytraced Scene

Raytraced Scene