This isn't right.

posted in Rendering Is Fun
Published April 29, 2012
Advertisement
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...
Previous Entry New journal!
Next Entry Ready, set, go!
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement