模型视图投影矩阵的用途 [英] The purpose of Model View Projection Matrix

查看:27
本文介绍了模型视图投影矩阵的用途的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用模型视图投影矩阵的目的是什么?为什么着色器需要模型视图投影矩阵?

For what purposes are we using Model View Projection Matrix? Why do shaders require Model View Projection Matrix?

推荐答案

模型、视图和投影矩阵是三个独立的矩阵.模型从对象的局部坐标空间映射到世界空间,从世界空间到相机空间的视图,从相机到屏幕的投影.

The model, view and projection matrices are three separate matrices. Model maps from an object's local coordinate space into world space, view from world space to camera space, projection from camera to screen.

如果您将所有三个组合在一起,您可以使用一个结果从对象空间一直映射到屏幕空间,使您能够计算出需要从传入的可编程管道传递到下一阶段的内容顶点位置.

If you compose all three, you can use the one result to map all the way from object space to screen space, making you able to work out what you need to pass on to the next stage of a programmable pipeline from the incoming vertex positions.

在旧的固定功能管道中,您将模型和视图一起应用,然后使用从它们派生的另一个结果计算照明(进行一些修复,例如,即使您应用了一些缩放,法线仍然是单位长度到对象),然后应用投影.你可以看到这反映在 OpenGL 中,它从不分离模型和视图矩阵——将它们作为单个模型视图矩阵堆栈.因此,您有时也会在着色器中看到这一点.

In the fixed functionality pipelines of old, you'd apply model and view together, then work out lighting using another result derived from them (with some fixes so that e.g. normals are still unit length even if you've applied some scaling to the object), then apply projection. You can see that reflected in OpenGL, which never separates the model and view matrices — keeping them as a single modelview matrix stack. You therefore also sometimes see that reflected in shaders.

因此:着色器通常使用组合模型视图投影矩阵将您为每个模型加载的顶点映射到屏幕.这不是必需的,有很多方法可以实现相同的目标,这很常见,因为它允许所有可能的线性变换.正因为如此,它的一个较少组成的版本也是你以前固定管道世界的常态.

So: the composed model view projection matrix is often used by shaders to map from the vertices you loaded for each model to the screen. It's not required, there are lots of ways of achieving the same thing, it's just usual because it allows all possible linear transforms. Because of that, a lesser composed version of it was also the norm in ye olde fixed pipeline world.

这篇关于模型视图投影矩阵的用途的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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