Under which conditions can I leave out the perspective division?

↘锁芯ラ 提交于 2019-12-11 09:37:51

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/26967339/under-which-conditions-can-i-leave-out-the-perspective-division

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!