glsl refraction getting mapped upside down

2019-02-09 16:52发布

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

1条回答
我只想做你的唯一
2楼-- · 2019-02-09 17:23

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:

https://summerexplorations.files.wordpress.com/2011/07/marbles2.jpg?w=584

Real world example:

http://www.physicscentral.com/explore/pictures/images/crystal-ball_2.jpg http://www.physicscentral.com/explore/pictures/images/crystal-ball_2.jpg

查看更多
登录 后发表回答