OpenGLES 2.0:gl_VertexID 的等效物是什么?

7
我正在尝试通过动态计算顶点在数组中的索引位置来创建点网格。是否有类似于gl_VertexID变量可以从着色器中调用的等效物?或者其他不需要发送更多数据到GPU即可访问它们在数组中位置的方法?谢谢,Josh。
以下是我的顶点着色器:
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;
}

4
这并不是你原来问题的答案,但在GLES 3.0中已经添加了这个功能。http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf - nullspace
1个回答

14

不幸的是,在GLES2中没有类似于gl_VertexID的等效项。您必须自己创建并传递其他数据。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接