【问题标题】:distortion correction using vertex displacement使用顶点位移校正失真
【发布时间】: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


    【解决方案1】:

    仅基于 Cardboard Distortion vertex shader,您似乎错过了除以 z^2 的投影步骤。 Other 桶形失真方法假设 NDC 空间。

    // should be
    float r2 = dot(tmp.xy,tmp.xy)/(z*z);
    

    也根据维基页面

    桶形失真通常对 K1 有一个负值,而枕形失真有一个正值

    所以你的系数应该没问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      • 1970-01-01
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 2018-12-20
      • 2014-11-10
      相关资源
      最近更新 更多