Create a C++ program that can produce a ray traced image of a scene containing spheres and colored lights. The light that is reflected off of a sphere, or the illumination, should be calculated using the Phong reflectance model. You should create a light class and an intersection class to help write this program.

Phong reflectance calculates the illumination of a point on an object for each light in the scene as the sum of three different types of illumination. The first, ambient illumination, is calculated with the equation:

I

_{a}= K_{a}* i_{a}

Where K_{a} is the material's ambient reflectivity and
i_{a} is the light's ambient intensity. The diffuse
illumination is calculated with the equation:

I

_{d}= K_{d}* (|L| ⋅ |N|) * i_{d}

Where K_{d} is the material's diffuse reflectivity, N is the
normal of the surface of the sphere at the point of intersection, L is
the direction from the intersection point to the light, and
i_{d} is the light's ambient intensity. The specular illumination is calculated with the equations:

I

_{s}= K_{s}* (|N| ⋅ |L + V|)^{Ns}* i_{s}

Where K_{s} is the material's specular reflectivity, N is the
normal of the surface of the sphere at the point of intersection, L is
the direction from the intersection point to the light, V is the
direction from the intersection point to the camera, N_{s} is
the specular exponent, and i_{d} is the light's ambient
intensity.

If |L| ⋅ |N| is less than 0, then the light is on the back side of the surface and the diffuse and specular illumination should not be added to the total illumination. If there is an object between the intersection point and the light, then the object is in shadow and the diffuse and specular illumination should not be added to the total illumination. Note, you can determine if a point is in shadow by creating an intersection function that returns true if any intersection occurs with a ray and any object in the scene. The ray passed to this function should have the intersection point as its origin, the light vector as the direction, the distance from the intersection point to the light as the maximum parametric distance, and a very small value for the minimum parametric distance.

The location and illumination of a light is specified in a scn file with a line that begins with "light". A light line looks like:

light p

_{x}p_{y}p_{z}a_{r}a_{g}a_{b}d_{r}d_{g}d_{b}s_{r}s_{g}s_{b}

Where p is the position of the camera, a is ambient intensity, d is the diffuse intensity, and s is the specular intensity. A scene can contain multiple lights. The illumination at an intersection point is the sum of the illumination of all the lights in the scene.

The scene class intersection method should be modified to return an intersection object. The intersection class represents the intersection of a ray and a sphere. It should have member data for the location of the intersection, the surface normal, the view vector, and the material of the surface. The scene class should also have a function that computes the illumination given an intersection point.

Tar your code in a file that contains your name and submit it on the course Inquire site.