glsl折射上下颠倒映射 [英] glsl refraction getting mapped upside down

查看:148
本文介绍了glsl折射上下颠倒映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在glsl中实现折射.我正在使用片段着色器中提供的折射功能来获得所需的效果.但是我得到的折射是颠倒的.我认为这是错误的..知道为什么会这样吗?

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;

然后执行片段着色器:

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:

真实世界的示例:


(来源: physicscentral.com )


(source: physicscentral.com)

这篇关于glsl折射上下颠倒映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆