反向透视投影
我用来
worldview_inverse * (projection_inverse * vector)
将屏幕空间坐标转换为世界空间坐标。 我假设它将
(x,y,1,1)
变换为远平面上的点,同时
(x,y,-1,1)
变换为近平面上的点,并且连接线我可以查询与线相交的视锥体中的所有对象。 转换后,我将结果点除以它们各自的 .w 分量。 这适用于远平面,但近平面上的点以某种方式转换为世界空间原点。
我认为这与我输入逆投影的 1 的 w 分量有关,因为通常在投影之前它是 1,而不是之后,而且我正在进行逆投影。 我究竟做错了什么?
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.
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. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这只是一种解决方法,但您可以仅使用远点和观看位置来推断近平面点。
至于你真正的问题。 首先,别忘了除以 W! 另外,根据您的投影矩阵,您是否尝试过 (x,y,0,1) 而不是 z=-1。
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.
As for you real problem. First, don't forget to divide by W! Also, depending on your projection matrix, have you tried (x,y,0,1) as opposed to z=-1.