I am implementing refraction in glsl. I am using the refract function provided in frag shader to get the desired effect. But the refraction I am getting, its upside down. I think this is wrong.. any idea why is it so?
This is what I do in vertex shader:
vec3 worldView = normalize(vec3(WorldCameraPosition-worldPos));
refractor = refract(-worldView, worldNorm, Eta); // eta = 0.66;
and then frag shader I do:
vec4 refractColor = textureCube(cubeMap, refractor);
http://www.cse.ohio-state.edu/~duttas/Images_5542/Capture.PNG http://www.cse.ohio-state.edu/~duttas/Images_5542/Capture.PNG
If you're talking about the refractions on those spheres, I'm pretty sure what you've got is the correct result, it's supposed to be upside down. Due to the way the light refracts off the spherical surface the image you see in the sphere is reversed:
Real world example:
(source: physicscentral.com)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With