透视世界空间逆投影 [英] perspective to world space inverse projection

查看:39
本文介绍了透视世界空间逆投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将阴影功能扩展到我已经创建的作为课堂作业的现有 3d 渲染器.我正在尝试实现 2 pass z 缓冲区算法.我已经完成了第一遍并创建了深度图.然而,问题是我在屏幕空间中光栅化我的线条,所以我必须将我的坐标带回图像空间,因为深度图的 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 ???

我的意思是,我想做

[Xsp]inverse * [Xpi]inverse * [Xiw]inverse ,并将其与屏幕空间的 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.

这篇关于透视世界空间逆投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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