Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

This isn't right.

Posted by Bacterius, 29 April 2012 · 637 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