投影矩阵如何工作? [英] How does a projection Matrix work?

查看:61
本文介绍了投影矩阵如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为我的A级课程写一篇有关3D编程的论文.但是我在理解透视投影矩阵时遇到了一个严重的问题,我需要详细解释矩阵.我已经搜索了许多有关此主题的网站和youtube视频,但是几乎没有尝试回答为什么矩阵在该位置具有这些值的问题.基于此 http://www.songho.ca/opengl/gl_projectionmatrix.html 我能够找出行的工作原理,但我不理解其他三个行.

I have to write a paper for my A-Levels about 3D-Programming. But I got a serious problem understanding the perspective projection Matrix and I need to fully explain the Matrix in detail. I've searched a lot of websites and youtube videos on this topic but very little even try to answer the question why the Matrix has these values at that place. Based on this http://www.songho.ca/opengl/gl_projectionmatrix.html I was able to find out how the w-row works, but I don't understand the other three.

我决定仅将简单"版本用于对称视口(右手坐标):

I decided to use the "simpler" version for symmetric viewports only (right-handed Coord.):

我非常感谢您尝试向我解释前三行!

I am very thankful for every attempt to explain the first three rows to me!

推荐答案

矩阵的核心原因是将3D坐标映射到2D平面,并且距离越远的物体越小.

The core reason for the matrix is to map the 3D coordinates to a 2D plane and have more distant objects be smaller.

为此,一个简单得多的矩阵就足够了(假设您的相机位于原点并看着Z轴):

For just this a much simpler matrix suffices (assuming your camera is at origin and looking at the Z axis):

1 0 0 0
0 1 0 0
0 0 0 0
0 0 1 0

与该矩阵相乘,然后对w坐标进行重新归一化后,您便具有了确切的含义.每个x,y,z,1点都变为x/z,y/z,0,1.

After multiplying with this matrix and then renormalizing the w coordinate you have exactly that. Each x,y,z,1 point becomes x/z,y/z,0,1.

但是,由于没有深度信息(所有点的Z均为0),因此深度缓冲区/过滤器将不起作用.为此,我们可以为矩阵设置参数,以便深度信息仍然可用:

However there is no depth information (Z is 0 for all points) so a depth buffer/filter won't work. For that we can a a parameter to the matrix so the depth information remains available:

1 0 0 0
0 1 0 0
0 0 0 1
0 0 1 0

现在,结果点包含Z坐标中的反深度.每个x,y,z,1点变为x/z,y/z,1/z,1.

Now the resulting point contains the inverse depth in the Z coordinate. Each x,y,z,1 point becomes x/z,y/z,1/z,1.

额外的参数是使用比例尺和平移将坐标映射到(-1,-1,-1)-(1,1,1)设备框(如果不在其中的边界框,则不会绘制点)的坐标的结果.

The extra parameters are the result of mapping the coordinates into the (-1,-1,-1) - (1,1,1) device box (the bounding box where if you are outside of it the point won't get drawn) using a scale and a translate.

这篇关于投影矩阵如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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