You are here

Reflections: Images of Mine Self

Submitted by nathanieltroutman on Sat, 02/03/2007 - 12:23

So far all of our objects are dull and flat, we could easily make this more cool by adding in reflections. The technique is simple, we cast the ray from the eye, hit the object, and then cast another ray reflected off the object. This creates nice reflective objects, the first one only allows things to reflect once.

With only one reflection we can't get the hall of mirrors effect. In order for things to reflect of themselves in their reflections we need to increase the depth we will trace reflections. To see what I mean, notice in the image above, the blue sphere is reflected on the green sphere. In the following image, we can see the reflection of the green sphere on the blue sphere in the reflection of the blue sphere on the green sphere. We can really notice the double reflections in the right hand image which is a zoom-in on the red sphere of the left image.

In the image below we can see a class of problems in ray tracing called acne problems. This particular one is a reflection acne. The acne is the odd looking lines all over the image. Some cases look more like acne, lighting acne shows up as block dots all over the objects. The acne comes from the fact that computers can only represent finite numbers. There is only so much information that can be used to represent a number, in this case 64-bits.

This finite space means that we can only represent a finite amount of numbers. The side affect of this is that when we are doing intermediary calculations we can lose some of the number before getting to the final answer. Well, if we calculate the same number but reorder the operations we might get a slightly different answers. E.g. D * (A + B + C) is not guaranteed to equal D * A + D * B + D * C, especially if D is very large compared to A, B, or C. Here is a real example, lets some math, but we can only keep track of 4 digits per number. First we will add before multiplying:

1357 * (.2008 + .4026 + .0460 + .7003) =

1357 * (1.3497) = (Round)

1357 * 1.350 =

1831.95 = (Round)

1832

Now we will distribute the 1357 before adding:

1357 * (.2008 + .4026 + .0460 + .7003) =

(1357 * .2008) + (1357 * .4026) + (1357 * .0460) + (1357 * .7003)=

272.4859 + 546.3282 + 64.422 + 950.3071 = (Round)

272.5 + 546.3 + 64.42 + 950.3 =

1833.52 = (Round)

1834

Now to do it without rounding till the very end:

1357 * (.2008 + .4026 + .0460 + .7003) =

1831.5429 = (Round)

1832

And the two answers are not equal: 1832 vs 1834, there is about a 1% error between them, which might not seem like much, but if we keep getting a 1% error here, another over there, it will add up fast to be a serious problem.