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

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

问题描述

我必须为我的 A-Level 写一篇关于 3D 编程的论文.但是我在理解透视投影矩阵时遇到了一个严重的问题,我需要详细解释矩阵.我已经搜索了很多关于这个主题的网站和 YouTube 视频,但很少有人尝试回答为什么矩阵在那个地方有这些值的问题.基于这个 http://www.songho.ca/opengl/gl_projectionmatrix.html我能够找出 w-row 的工作原理,但我不了解其他三个.

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天全站免登陆