在哪些情况下我可以忽略视角分工? [英] Under which conditions can I leave out the perspective division?

查看:329
本文介绍了在哪些情况下我可以忽略视角分工?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在执行透视分割后恢复同质转换。更具体地说,我正在使用保守光栅化实现基于GPU的体素化算法。 >。对于一个概述,这些是我到目前为止实现的步骤(VS =顶点着色器,GS =几何着色器):


  1. 应用模型转换为顶点(VS)。
  2. 将正交投影转换应用于每个顶点(GS)的副本。
  3. 应用视图转换(GS)。
  4. 对副本(GS)执行透视分割。

  5. 根据屏幕坐标翻译复制的顶点(GS )。

接下来,我想从(3)中恢复视图变换并用不同的视图矩阵变换顶点。现在,我的问题是应用反向视图矩阵是否简单?当我只使用正交投影和仿射(旋转,平移,缩放)转换时,是否需要担心均匀坐标?在我看来,只有在正常转换时,我需要担心它,因为转置的逆并不是仿射变换。我无法找到关于这个主题的网络资源,也没有反例,所以我在这里问。

解决方案

一个正交投影矩阵如下,

  2 /(r  -  1)0 0 tx 
0 2 /( t - b)0 ty
M = 0 0 -2 /(f - n)tz
0 0 0 1

可以注意到,最后一行是[0,0,0,1]。这意味着,当将M与矢量[x1,y1,z1,1]相乘时,结果为[x2,y2,z2,1]。因此,在执行视角分割时,系统总是将分割为1.实际上,这意味着只要仅使用正交投影,就不必担心视角分割。


I want to revert a homogeneous transformation after performing a perspective division. To be more specific, I’m implementing a GPU-based voxelization algorithm using conservative rasterization. For an overview, these are the steps I’ve implemented so far (VS=vertex shader, GS=geometry shader):

  1. Apply the model transform to the vertices (VS).
  2. Apply an orthographic projection transform to a copy of each vertex (GS).
  3. Apply a view transform to the copies (GS).
  4. Perform a perspective division on the copies (GS).
  5. Translate the copied vertices based on screen coordinates (GS).

Next, I want to revert the view transform from (3) and transform the vertices with a different view matrix. Now, my question is whether it’s as easy as applying the inverse view matrix? Do I need to worry about the homogeneous coordinates at all when I only work with orthogonal projections and affine (rotation, translation, scaling) transformations? It seems to me that only with the normal transformations I need to worry about it since the transposed inverse is not an affine transformation. I could neither find a web resource on this topic nor a counter example, so I’m asking here.

解决方案

When looking at a orthographic projection matrix as the following,

     2/(r - l)    0        0       tx
        0     2/(t - b)    0       ty
M =     0         0    -2/(f - n)  tz 
        0         0        0       1

one can notice, that the last row is [0,0,0,1]. This means, that when multiplying M with a vector [x1,y1,z1,1], the result will be [x2,y2,z2,1]. Thus when performing the perspective devide, the system will always divide by 1. In practice this means, that you don't have to worry about the perspective devide as long as you are using only orthographic projections.

这篇关于在哪些情况下我可以忽略视角分工?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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