6
私は、シェーダに送られた頂点の配列のインデックスに基づいて、頂点の位置を動的に計算して点のグリッドを作成しようとしています。シェーダ内から呼び出せるgl_VertexID変数に相当するものはありますか?または、GPUにさらにデータを送ることなく、配列内の位置にアクセスする別の方法ですか?ありがとう、ジョシュ。OpenGLES 2.0:gl_VertexID相当ですか?
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;
}
元の質問に対する回答ではありませんが、これはGLES 3.0で追加されました。 http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf – nullspace