• entries
13
37
• views
30657

# This isn't right.

847 views

I just discovered the wierdest bug ever in my refraction (dieletric glass) code. One of the last few lines in its BSDF is this, which performs the actual refraction with computed angles (most of the code before is to do with Fresnel reflectance):

Ray.Direction := Ray.Direction * Index + Normal * (Index * Theta - Phi);

At some point in time, I changed the Index variable to IOR to make it more descriptive. I must have been tired, though, because unfortunately, the code became this instead:

Ray.Direction := Ray.Direction * Index + Normal * (IOR * Theta - Phi);

This compiled because Index was, in fact, renamed too to describe the material object's index (as in its position in the material array). So the refractions were horribly off. How this did not get spotted before is an open question - I only realized it tonight while creating a reference Cornell Box scene and wondering why my sphere wouldn't make nice caustics. This invalidates all of the scenes which include this material (I don't recall when this change occurred, so I have to assume all renders which do not display obviously correct refraction are invalid).

Now to recompute the possibly incorrect renders...

There are no comments to display.

## Create an account

Register a new account