Sign in to follow this  

Accuracy of the "refract" instruction in Shading Languages

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I was wondering if the refract instruction in GLSL-Cg is accurate from a physical point of view. I mean that, is the vectorial approach used to compute the refraction vector in GLSL-Cg gives the same result as if we applied the law of Snell-Descartes in Physics ? If it is an approximation, does someone know its quality ? Cheers, Jeff.

Share this post


Link to post
Share on other sites
Well... I don't know the answer to your question exactly... but I thought I'd say that refraction is mathematically straightforward so one would presume that someone would implement it correctly. The main problem I suppose is that the amount of refraction is determined by the difference in refractive index between the two media at the interface. If the shader doesn't allow for this... it presumably assumes that all materials are in an background vacuum (optically). This is fine for most purposes... but it'd mean that an object with the same refractive index as water would still refract even in placed in water. This is a generic problem I'd guess as you'd need to understand the volumetric properties of the material for this to operate (like the interior and media options in a raytracer like povray). I guess if you want anything better you'll have to come up with something yourself from scratch. As to testing the quality... why not try a simple test like a ball on a checkerboard floor and compare to a true raytraced image?
Hope this helps,

Dan

Share this post


Link to post
Share on other sites

This topic is 3735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this