OpenGL ES:禁用转换?
这个 NVIDIA 视频播客(已过时?)建议绕过 OpenGL 的矩阵堆栈,如下所示性能提示。它还建议绕过 OpenGL 的照明,这意味着他们的意图是实际手动转换几何体。无论如何,我碰巧这样做是出于其他原因。
当然,除非有办法让 OpenGL 禁用它自己的转换,否则您实际上会从中受益是没有意义的。 AFAIK 没有明确的方法来做到这一点,并且视频也没有给出任何提示。
当然,这可以通过将恒等式加载到 gl 的矩阵中来逻辑地完成。如果矩阵是恒等矩阵,我是否应该期望一个体面的实现实际上完全跳过转换?
This NVIDIA video podcast (dated?) suggests bypassing OpenGL's matrix stack as a performance tip. It also suggets to bypass OpenGL's lighting, which implies that their intention is to actually transform the geometry manually. I happen to do this anyway for other reasons.
Ofcourse, it doesn't make sense that you'll actually benefit from this unless there's a way to have OpenGL disable it's own transformations. AFAIK there's no explicit way to do this, and the video doesn't give any hints about this either.
It can be logically done, ofcourse, by loading identity into gl's matrices. Should I expect a decent implementation to actually skip a transformation altogether if a matrix is identity?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它指的是您可以将矩阵压入和弹出到 OpenGL 堆栈的事实。也避免做像 glTranslate 之类的事情。这样你就可以自己完成所有的矩阵乘法等,并且它绝对不会经过浮点模拟。然后直接设置矩阵即可。
至于照明,您可以使用 glDisable 来实现。看起来他们纯粹是使用纹理照明。基本上,您将灯光绘制到环境贴图纹理上。这为您提供了定向光的效果,您可以添加任意数量的灯光,唯一增加的成本是创建环境贴图。虽然设置环境贴图相当复杂,但它绝对可行,并且给出了非常好的结果(您可以使用类似的技巧来获得早在 DX6 的漫反射 DOT3 凹凸贴图!)
他们可能正在谈论自己在顶点上进行照明将数据添加到引擎时。即运行法线和位置,并使用固定点执行照明计算,然后使用 glColorPointer 将它们传递到 GLES。这是一件非常简单的事情,而且定向顶点光照也很容易(NL,其中 N 是顶点法线,L 是模型相对空间中的光线方向)。
Its referring to the fact that you can push and pop matrices on to the OpenGL stack. Avoid doing things like glTranslate and such like as well. This way you can do all your matrix multiplies etc yourself and it definitely won't be going through the floating point emulation. You then just set the matrix directly.
As for the lighting you do that by using glDisable. It looks like they are, purely, using texture lighting. Basically you paint the lights on to an environment map texture. This give you the effect of directional lights and you can add as many lights as you like and the only increased cost is in creating the environment map. Its quite complicated setting up the environment map though but its definitely doable and gives really nice results (You could use a similar trick to get diffuse DOT3 bump mapping as far back as DX6!)
They may be talking about doing the lighting yourself on your vertex data as you add it to the engine. ie Run through your normals and positions and perform the lighting calculation using fixed point before passing them to GLES with a glColorPointer. This is a VERY simple thing to do and to do directional vertex lighting is easy (N.L where N is the vertex normal and L is the light direction in model relative space).