For each component, there is a shape per line: each such line starts with the keywords "SOLID" or "HOLLOW". A shape is cube, cylinder, or box. For hollow shape only surface interaction of light is to be considered, whereas for a solid shape, volumetric interaction is to be simulated using ray-marching with some rays absorbed and others scattered by the medium. Naturally, "many" rays will be needed to traverse the medium. Each shape has (one of) the following forms following the "SOLID" or "HOLLOW" keywords on a line:
BOX h x1 y1 z1 x2 y2 z2 x3 y3 z3
CYLINDER r x1 y1 z1 x2 y2 z2
SPHERE r x1 y1 z1
The box is a cuboid, and the coordinates of its vertices A, B, and C are listed one after another. ABC forms a plane. The fourth vertex in the same plane needs to be computed to form a parallelogram ABCD. The box is h units high in the direction d = |(B-A)X(C-B)|, i.e., the other four points are A+hd, B+hd, etc.
The cylinder's axis is listed, as well as its radius about that axis.
The sphere's center and radius are listed.
The material properties comprise a sequence of 32 real-valued numbers. The first is the refractive index, the next three are the X Y Z spectral absorption coefficients, and the fifth is the uniform scattering coefficient. The remaining 27 are in triples of X Y Z, each value in the normalized range 0 to 1. The first X Y Z triple represents the (uniformly distributed) irradiance emitted from every point on the surface of the component. The next 12 represent surface BRDF, again normalized in the range 0-1 (with respect to the total reflected light). These are samples at θr = 0, π/6, π/3, and π/2. The full BRDF wrt ≤ θr ≤ π/2 is a linear interpolation of these sample values, and is 0 outside this range. Similarly, the subsequent 12 numbers represent BTDF samples. Here θr is the angle from the ideal direction of reflection for BRDF and from refraction for BTDF. BRDF and BTDF are independent of incoming and outgoing φ.
Here, xc yc zc represent the position of the camera and xf yf zf the point the camera looks at. The upward orientation is always 0 1 0.
You should trace at least one ray per pixel. However, the goal is to generate anti-aliased images -- you will need to discover how many rays to trace starting at each point. Be particularly careful with grazing incidences. Time taken will not be graded, but try to stay within a few tens of seconds for a model file with, say, 10 solids.
Note: Please start planning and reading up. Example model and camera files are available.
Resources: Use GLFW for creating a window and use OpenGL to push images to the screen. Use stb_image.h to read and write PNG files.
-- The URL of this page is: http://www.cse.iitd.ac.in/~subodh/courses/CSL781/a1_ray.html --