webgl - 伪圆柱投影的投影矩阵

标签 webgl projection projection-matrix

想象一下,在一个球体中包含一组混合的 3D 对象,您的目标是创建一个 cylindrical equal-area projection整个场景。使用 OpenGL,您可能会考虑通过围绕中心轴旋转相机将多个渲染目标纹理(准确地说是 4 个)拼接在一起,然后在后处理着色器中校正径向失真,因为您要投影到平面而不是圆筒。理想情况下,您可以在没有任何重叠的情况下将相机的截头体扫过球体的整个体积,并且每次渲染都填充矩形纹理的整个像素空间(如圆柱投影那样)。

因此,为了清晰起见,这里是球形场景(其中包含对象)的可视化,以及围绕 Y 轴跨越 PI/2 的相机视锥。
Visualization of a cylindrical projection camera frustum

请注意,“远”平面被缩减为一条线,该线与球体的 Y 轴共线。在视锥体的外表面上形成“X”的白色相交线代表相机的原点,或眼空间中的 (0,0,0)。该外表面也是“近”平面,位于距相机 0 Z 单位的位置。

这个想法是球体的中心轴向外转换光线,使得所有光线都平行于 Y 平面(即具有法线 (0, 1, 0) 的平面),并且每条光线都从球体的 发出。产地以垂直角度与球体表面相交。

我的问题:

天真地,我认为 OpenGL 投影矩阵可以做到这一点——据我所知,我在这里进行的投影是线性的,因此可能吗?但是,我似乎无法正确求解方程:

let s be the radius of the sphere.

So, in eye-space, from the camera's origin:
  • the left and right edge of the near plane are located at -s and s units along the X-axis, respectively
  • the top and bottom edge of the near plane are located at s and -s units along the Y-axis, respectively
  • the left and right edge of the far plane are co-located at -s units along the Z-axis (keep in mind that in eye-space, Z values are negative in front of the camera)
In the OpenGL projection matrix:
  • -w_c < x_c < w_c
  • x_n = x_c / w_c

Since the left and right frustum planes converge in front of the camera, I solved for an equation that maps my inputs to their expected outputs and concluded that:
  • x_n = x_e / (z_e + s)
Which means that x_c = x_e and w_c = z_e + s. This fills in two rows on my projection matrix:

yea


---------- This is where I get stuck ----------

It's clear that y_n does not depend on x_e or z_e at all, and that its equation should be:
  • y_n = y_e / s
This is akin to an orthographic projection. However, this introduces a conflict with the w_c I already solved for in the x_n equation.


我按照 this article 中的步骤导出了上面的投影矩阵,它简洁地解释了 OpenGL 的透视和正交投影矩阵的推导。

看来我可能遇到了线性变换的限制? 如果这确实是非线性的 ,那么我不明白为什么,希望得到解释:)

最佳答案

由于您的投影需要 y = sin(phi)映射是非线性的。

理论上,使用 4x4 矩阵(连同齐次坐标),您可以描述比线性变换更具表现力的仿射变换。仿射变换的形式为 a * x + b其中 a 和 x 是向量,b 是标量值。没有办法如何用它来表达三角函数。

关于webgl - 伪圆柱投影的投影矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46151527/

相关文章:

canvas - 在 Three.js 中,与 Canvas 相比,我使用 WebGL 渲染的任何内容都非常模糊

javascript - 带有 WebGL 的服务器端 javascript?

javascript - 三 Angular 测量 + 线性插值 + 3D 投影的毛刺

matrix - 如何从里程计/tf 数据中获取投影矩阵?

javascript - 如何使用 glslsandbox.com 的片段着色器

javascript - WebGL 纹理创建麻烦

computer-vision - 单应性估计-> 导致仿射矩阵?

python - 具有不规则二维 numpy 数组的 Matplotlib basemap + contourf

opengl - 为什么相机默认面向z轴负端?

opengl-es - 如何从 Projection 和 ModelView 矩阵中获取 CATransform3D?