OpenGL ES attribute transfer default behaviour when dimensions don't match

后端 未结 1 997
天涯浪人
天涯浪人 2021-01-27 12:44

Running a very simple OpenGL ES example I\'ve seen that the dimensions of the position attribute in the vertex shader and the ones used to transfer the attribute data to the GPU

相关标签:
1条回答
  • 2021-01-27 13:28

    The value of w will be 1.0 in this case. This is perfectly legal and well defined. Whenever the specified attribute has fewer values than 4, the missing values are padded with values from (0.0, 0.0, 0.0, 1.0). Of course, if the attribute vector in the vertex shader is shorter, not all those values are used.

    The relevant spec language is on page 21 of the ES 2.0 spec, under "Transferring Array Elements":

    When an array element i is transferred to the GL by the DrawArrays or DrawElements commands, each generic attribute is expanded to four components. If size is one then the x component of the attribute is specified by the array; the y, z, and w components are implicitly set to zero, zero, and one, respectively. If size is two then the x and y components of the attribute are specified by the array; the z, and w components are implicitly set to zero, and one, respectively. If size is three then x, y, and z are specified, and w is implicitly set to one. If size is four then all components are specified.

    0 讨论(0)
提交回复
热议问题