Jump to content
  • Advertisement
  • entries
  • comments
  • views

This isn't right.

Sign in to follow this  


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...
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!