Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

This isn't right.

Posted by , 29 April 2012 · 762 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...

Recent Comments

Latest Visitors