透视到世界空间投影反透视、世界、空间

2023-09-08 10:52:37 作者:北悸安凉

我是延长阴影特征,以我的,我已经创建了我那一届学生的家庭作业已经存在的3D渲染器。我想实现2通Z缓存算法。我已经做第一遍并创建了深度图。然而,问题是,我栅格化我行的屏幕空间,所以我不得不把我的坐标回图像空间,作为深度图z值,该片段坐标之间的比较发生在图像空间。

i am extending shadow feature to my already existing 3d renderer that i have created as my class homework. I am trying to implement 2 pass z buffer algorithm. I have already done the first pass and created the depth map. However, the issue is that i rasterize my lines in screen space and so i have to bring my coordinates back to image space, as the comparison between z value of depth map and that of the fragment coordinates takes place in image space.

我用一个堆栈实现存储空间的转换矩阵形式如下:

I use a stack implementation which stores the space transformation matrices in the following form :

[XSP] * [XPI] * [Xiw] *(X,Y,Z)在世界空间= X,Y,Z坐标在屏幕空间 其中,XSP - 的角度来筛选 XPI - 图像透视 Xiw - 世界图像

[Xsp] * [Xpi] * [Xiw ] * (x,y,z) coordinates in world space = x,y,z in screen space where Xsp - perspective to screen Xpi - image to perspective Xiw - world to image

下面,对堆栈的底部包含XSP,第二至底部包含,XSP乘以XPI,第三至底部包含XSP * XPI乘以Xiw结果.....

Here, the bottom of the stack contains Xsp, second to bottom contains, Xsp multiplied with the Xpi, third to bottom contains the result of Xsp * Xpi multiplied by Xiw .....

现在,我只希望X,Y,Z的图像空间, 这是(Xiw * X,Y,Z世界空间),因此让X,Y,Z在世界空间将工作对我来说... 是否有可能实现,如果我乘以每个矩阵的逆,然后乘以结果用X,Y,Z的屏幕空间???

now, i only want x,y,z in image space , that is (Xiw * x,y,z in world space), so getting x,y,z in world space will work for me... Is it possible to achieve if i multiply the inverse of each matrix and then multiply the result with x,y,z in screen space ???

我的意思是,我想要做的。

I mean, i want to do

[XSP]逆* [XPI]逆* [Xiw]相反,繁衍这与x的屏幕空间,Y,Z 将它让我回到世界空间??

[Xsp]inverse * [Xpi]inverse * [Xiw]inverse , and multiply this with x,y,z of screen space will it get me back to world space ??

推荐答案

让我猜。南加州大学CS580?

Let me guess. USC CS580?

无论如何,我会帮助你。

Anyway I'll help.

如何您最初得到你的顶点:

Xsp * Xpi * Xiw * Xwm * v = vf //Concat * model-space vertex = raster-space vertex

vf' = (vf.x / vf.w, vf.y / vf.w, vf.z / vf.w); //Perspective

你怎么把它找回来与VF:

Xwm * vf = Xiw^-1 * Xpi^-1 * Xsp^-1 * vf' //Inverted partial concat * raster-space vertex = world-space vertex

v = (vf.x / vf.w,  vf.y / vf.w, vf.z / vf.w); //Perspective again

通常是相同​​的想法,除非你只需要倒Xiw回到世界的空间,因为法线只能到图像空间。也没有角度参与。

Normal is the same idea except you only need an inverted Xiw to go back to world space since normals only go to image space. There is also no perspective involved.