OpenGLES 2.0:是否具有gl_VertexID? [英] OpenGLES 2.0: gl_VertexID equivalent?
本文介绍了OpenGLES 2.0:是否具有gl_VertexID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图根据发送到着色器的顶点数组中的索引,通过动态计算顶点位置来创建点的网格.是否可以在着色器中调用gl_VertexID变量的等效项?还是另一种无需在GPU中发送更多数据即可访问它们在阵列中的位置的方法?谢谢,乔什.
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.
这是我的顶点着色器:
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;
}
推荐答案
不幸的是,GLES2中没有gl_VertexID等效项.您必须自己创建并传递其他数据.
Unfortunately there is no gl_VertexID equivalent in GLES2. You must create and pass additional data yourself.
这篇关于OpenGLES 2.0:是否具有gl_VertexID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文