简体   繁体   English

反向透视投影

[英]reverse perspective projection

I'm using 我正在使用

worldview_inverse * (projection_inverse * vector)

to transform screen space coordinates into world space coordinates. 将屏幕空间坐标转换为世界空间坐标。 I assumed that 我认为

(x,y,1,1)

would transform to a point on the far plane, while 会转变到远处飞机上的一个点,而

(x,y,-1,1)

transforms to a point on the near plane, and connecting the line I can query all objects in the view frustum that intersect the line. 转换到近平面上的点,并连接线我可以查询视线平截头体中与线相交的所有对象。 After the transformation I divide the resulting points by their respective .w component. 在转换之后,我将得到的点除以它们各自的.w分量。 This works for the far-plane, but the point on the near plane somehow gets transformed to the world space origin. 这适用于远平面,但近平面上的点以某种方式转换为世界空间原点。

I think this has to do with the w components of 1 I'm feeding into the inverse projection, because usually it is 1 before projection, not after, and I'm doing the reverse projection. 我认为这与我投入逆投影的w分量有关,因为通常在投影之前是1,而不是之后,我正在进行反投影。 What am I doing wrong? 我究竟做错了什么?

I know this is only a workaround, but you can deduce the near plane point by only using the far point and the viewing position. 我知道这只是一种解决方法,但你可以通过仅使用远点和观察位置来推断出近平面点。

near_point = view_position
           + (far_point - view_position) * (near_distance / far_distance)

As for you real problem. 至于你真正的问题。 First, don't forget to divide by W! 首先,别忘了除以W! Also, depending on your projection matrix, have you tried (x,y,0,1) as opposed to z=-1. 此外,根据您的投影矩阵,您尝试过(x,y,0,1)而不是z = -1。

near_point = worldview_inverse * (projection_inverse * vector)
near_point /= near_point.W

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM