Implement the Fixed function Pipeline efficent in OpenGL ES 2.0?

独自空忆成欢 提交于 2019-12-07 20:18:26

Identity, translation, rotation, and scaling matrices don’t require a full matrix multiplication to apply, because many of the terms are always 0.0 or 1.0. If you write out the element-by-element results of multiplying other matrices by these matrices, you’ll see that many elements may only have a few terms contributing to their final values. Two simple examples:

  • Given the identity matrix I and an arbitrary matrix M, I × M = M × I = M.
  • The only non-zero elements in a scaling matrix S are the four along the diagonal, which we’ll call S0, S1, S2, and S3. (S3 is always 1.0 for something like glScalef.) S × M scales the nth row of M by Sn. M × S works column-by-column instead. You can also think of the identity matrix as a particularly boring scaling matrix.

The resulting element-by-element expressions for translations and rotations are a bit more complicated than these examples, but still greatly simpler than a full matrix multiplication. (Rotations also get a great deal simpler if the axis of rotation is exactly aligned with the X, Y, or Z axis.) You’ll probably want to look into modifying matrices directly when asked to translate, scale, or rotate, rather than constructing another matrix and multiplying.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!