Implement a recursive ray tracer using C/C++. Use GLFW for implementing the keyboard interface and for displaying your framebuffer in a window. You will render a culinary scene made of sphere, cylinders and rectangles.
Model
The scene contains a wet white floor, a table made of solid dark brown glass. On the table is a single silver plate in the center of the table with a single golden bowl placed at the center of the plate, and four glass tumblers around the plate, each half-filled with colored fluid.
The floor is a square 100 units across.
The table is centered on the floor and 75x75 units. Four cuboidal legs of the table are 2x2 units wide and 75 units high. The table-top is 1 unit thick.
The plate is a disk with a radius of 10 units and a height of 1 unit.
The bowl is a hemisphere of radius 5 units.
The tumblers are cylindrical glass with thickness of 1 unit. Each has a height of 10 units and external radius of 3 units. They are evenly spaced around the plate, each touching the plate,
The table and tumblers diffuse 35% of the refracted light and allow 65% to pass through.
The plate and the bowl reflect 90% of the light, half of that specularly.
!-->
The floor is mirror-like smooth due to the water. It takes albedo of the floor and reflectance of water.
Use four directional light sources: each is 75 units above the four corners of the table pointed at the center of the table-top. Two of these on one side of the table are bright yellow and other two are bright cyan.
Also deploy a bright white 2x2-unit area-light source 10 units above the table.
Illumination
Use the following to illuminate your scene.
Use Cook/Torrance + Blinn/Phong illumination model with diffuse, specular and ambient components.
Choose appropriate camera exposure
Use recursion depth of 4 (each intersection counts once), refraction and shadows.
You may assume the following (R,G,B) values of Fresnel Reflectance at normal incidence (F0)
Water = (0.02, 0.02, 0.02)
Glass = (0.08, 0.08, 0.08)
Gold = (1.00, 0.71, 0.29)
Silver =(0.95, 0.93, 0.88)
You may look up parameters for refractive indices of glass, silver, and gold in the literature.
Experiment with albedo parameters.
The water in tumblers are, respectively, colorless, wine-red, bright-orange, and lemon-yellow.
Experiment with roughness parameter m near 0.2 for gold, 0.3 for silver, and 0.1 for glass.
Viewing and Interface
The rendering should be somewhat interactive. Try to complete a frame in less than one second with 1024x768 pixels, preferably with at least eight samples per pixel and at least eight samples for the area-light. Implement the following interface to allows the viewer to rotate the entire scene and control illumination.
Allow the window size to be changed by the viewer.
The area-light source is initially turned on, and key l (with the cursor captured by your application window) toggles its switch.
The area-light should be movable using keys a,b,c,d, and e. Key c indicates that the light is centerd above the table-top's center. The other keys indicate the four corners of the table, respectively.
Letter t toggles Cook-Torrance (initially applied). When Cook-Torrance illumination model is off, use Blinn-Phong non-physically based illumination instead.
Allow the camera to be moved along the latitudes and logitudes of a sphere centerd at the table-top's center. The radius of this sphere should be such that the entire scene fits the window. Use left and right arrow keys to move along the lattitude by 15° Up and down arrows should move the camera along the longitude by 15°.
Assuming that the equator lies in the plane of the table top, the initial camera position should be 5°N, any longitude.
** Revised: Sat, 5 Feb 2021 by Subodh Kumar
-- The URL of this page is: http://www.cse.iitd.ac.in/~subodh/courses/CSL781/raytrace.html --