为什么投影矩阵必须是双倍的?
问题是,我有一个 ModelViewProjection(MVP) 矩阵,它是由 ModelView 与 Projection 相乘而成的;我制作了一些与 glOrtho 和 gluPerspective 执行相同操作的函数,以摆脱 OpenGL 弃用堆栈功能。我的函数返回双精度值。我的着色器使用 modelviewprojection 作为浮动。是否有必要对透视矩阵使用 double 进行操作,因为最终 MVP 会浮动?矩阵由 float[16] 或 double[16] 组成;如果 double 没有显着的好处,那么我会在进入着色器之前节省一些 CPU 资源来将投影矩阵 double 转换为浮动到某处。
Here is the problem, I have a ModelViewProjection(MVP) Matrix that is made from multiplying ModelView with Projection; I have made some functions that does the same thing as glOrtho and gluPerspective to get rid of the OpenGL deprecation stack feature. My functions return double values. My shaders use modelviewprojection as float. Is there any necessity on operating with double for the perspective matrixes because finaly the become floats in MVP? matrixes are made of float[16] or double[16]; If there is no notable benefit in double, then I spare some cpu resources on casting projection matrix double to float somewhere before getting in shaders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以坚持使用
float
。典型的 DX10/GL3.x 级硬件(例如我的 Geforce 9800GT)根本不支持双精度浮点数学。早期的 DX9 级 ATI 卡甚至无法在硬件中正确支持单精度浮点数学(如果我没记错的话,它们支持 fp24 之类的东西)。
尽管如此,投影在任何此类卡上的各个方面都表现得很好。这表明在这种情况下并不真正需要额外的精度。
You can stick with
float
.Typical DX10/GL3.x-class hardware (such as my Geforce 9800GT) does not support double precision floating point math at all. Earlier DX9-class ATI cards did not even properly support single-precision floating point math in hardware (they supported something like fp24 or so if I remember correctly).
Nevertheless, projection works just fine in every respect on any such card. Which shows that the extra precision is not really needed in this case.
您可以使用其中一个或两者,出于性能原因,人们通常只使用浮点数进行图形处理。
You can use either or both, for performance reasons it is usual for people to just use floats for graphics processing.