【发布时间】:2017-02-03 07:49:53
【问题描述】:
我正在尝试使用顶点位移为 google Cardboard 创建一个带有 QT 和 OpenGL-ES 的小型 VR 演示,如 here 所述。
简短:它对每个顶点应用棕色康拉迪模型来抵消透镜畸变,公式如下:
x/y_distorted = x/y_undistorted * (1.0 + K1 * r^2 + K2 * r^4)
作为系数,我从 gvr 的 java 源代码中得到 K1 = -0.55 和 K2 = 0.34。
这是相关的着色器代码:
vec4 tmp = vec4(a_position,1.0);
tmp = uMVMat * tmp; //Applying the ModelView Matrix
float r2 = dot(tmp.xy,tmp.xy); //Calculating the squared radius
tmp.xy *= 1.0f + (-0.55+0.34*r2)*r2; //Applying the Formula to x and y
gl_Position = uPMat * tmp;
这会在渲染平面时产生以下图片: Distorted Plane
我做错了什么?我什至尝试过交换系数,反转它们,......我总是得到某种枕形失真......
【问题讨论】:
标签: opengl-es glsl google-cardboard virtual-reality