OpenGLES 2.0: gl_VertexID equivalent?

前提是你 提交于 2019-12-22 05:10:07

问题


I'm 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 of the gl_VertexID variable that I can call from within my shader? Or another way of accessing their position in the array without having to send more data to the GPU? Thank, Josh.

Here's 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;
}

回答1:


Unfortunately there is no gl_VertexID equivalent in GLES2. You must create and pass additional data yourself.



来源:https://stackoverflow.com/questions/10044185/opengles-2-0-gl-vertexid-equivalent

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