OpenGLES 2.0: equivalent to gl_VertexID?

I am trying to create a grid of points by calculating vertex positions dynamically based on their index in the array of vertices sent to the shader. Is there an equivalent to the gl_VertexID variable that I can call from my shader? Or another way to access your position in an array without having to send more data to the GPU? Thanks, Josh.

Here is my vertex shader:

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; } 
+6
source share
1 answer

Unfortunately, GLES2 does not have the equivalent of gl_VertexID. You must create and transfer additional data yourself.

+12
source

Source: https://habr.com/ru/post/912601/


All Articles