OpenGLES 2.0:gl_VertexID等价?

Jos*_*osh 6 glsl vertex vertex-shader opengl-es-2.0

我正在尝试通过动态计算顶点位置来创建点网格,这是基于它们在发送到着色器的顶点数组中的索引.是否有我可以在着色器中调用的gl_VertexID变量的等效变量?或者另一种访问阵列中位置的方法,而不必向GPU发送更多数据?谢谢,乔希.

这是我的顶点着色器:

attribute vec4 vertexPosition;
uniform mat4 modelViewProjectionMatrix;
vec4 temp;
uniform float width;

void main()
{    
    temp = vertexPosition;

    // Calculate x and y values based on index:
    temp.y = floor(gl_VertexID/width);
    temp.x = gl_VertexID - width*temp.y;

    gl_Position = modelViewProjectionMatrix * temp;
}
Run Code Online (Sandbox Code Playgroud)

Mār*_*iko 13

不幸的是,GLES2中没有gl_VertexID等价物.您必须自己创建并传递其他数据.