A: Let's aim for Monday, Feb. 6th, in class.
A: Feel free to use your own, or to modify the existing file format as presented in the assignment page.
A: It depends on the type of object:
A: I suggest that you either modify the file format to omit the center and radius info, or to ignore that info. The transformation matrix will do the work of placing and sizing the sphere for you.
A: Well, it costs a lot of CPU time to invert a matrix, so it's best to invert the matrix ONCE when the scene is built, not every time you intersect a ray and an object.
A: When light hits a surface, some is absorbed, some transmitted into it, and some reflected away. Thus there are three coefficients. Each is a number from 0.0 to 1.0, representing a fraction of light, and these three coefficients add up to 1.0. Hence, both absorption and reflection coeffs are from 0 to 1, and absorption + reflection is less than 1.0.
This ignores color, of course. In practice, there will be three absorption and three reflection coeffs (red, green and blue) per surface (per object).
A: Each object will represent the boundary of a solid region. This includes triangles, so your images may not look plausible if the triangles don't join up to enclose a solid region.
The indexes of refraction ni and nt (the incident and transmitted indexes of refraction) should probably be attributes of rays (see the next answer). The index of refraction of air or vaccuum is essentially 1.0, while the index of refraction of common transparent objects is from 1.3 to 2. For each refraction, you need to know if you are entering or leaving the solid region, in order to assign the correct values to ni and nt. A simple way is to look at c = N dot L in the pseudocode. If it's positive, you're entering, and if negative, you're leaving (why?).
One caveat: don't forget to advance the starting point of your reflected and transmitted rays a little bit, to make sure the ray starts clearly in the correct side of the surface (see the pseudocode). Otherwise, numerical error will likely cause rays to intersect the very object they are leaving from! This results in grainy "acne" on the surface.
A: Initially, only substances (surfaces) have indexes of refraction, which are stored when the scene is initialized (read from a data file). When tracing happens, rays acquire the index of refraction of whatever region they are traveling through. Here is a tabular summary:
| Event | How to detect event |
Incoming ray n |
Reflected ray n |
Transmitted ray n |
|---|---|---|---|---|
| Entering Object |
N dot L < 0 | ni = 1 (vaccuum) | n = 1 (vaccuum) | nt = material's n |
| Leaving Object |
N dot L > 0 | ni = material's n | n = material's n | nt = 1 (vaccuum) |
A: I think it's simplest not to store 16 numbers in your input file, because it will be hard for you to remember what they mean. It's better to keep a current matrix (which gets reset to the identity matrix when necessary), and apply successive simple transformation matrices to it. Thus your data file could specify a translated, rotated and scaled sphere sort of like this:
A: I think it's easiest to build them as you read the objects.
For a sphere, use the unmatrix code I gave you to
extract the transformation matrices, and deduce the bounding
sphere from that. For triangles, find the average of the
vertices' coords to get the sphere center, and then get the
radius (this is not the tightest sphere possible, but will
provide some acceleration).