gpt4 book ai didi

glsl - OpenGLES 2.0 : gl_VertexID equivalent?

转载 作者:行者123 更新时间:2023-12-02 05:17:36 27 4
gpt4 key购买 nike

我正在尝试根据发送到着色器的顶点数组中的索引动态计算顶点位置来创建点网格。是否有可以从着色器中调用的 gl_VertexID 变量的等效变量?或者另一种访问它们在数组中的位置而无需向 GPU 发送更多数据的方法?谢谢,乔什。

这是我的顶点着色器:

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。您必须自己创建并传递附加数据。

关于glsl - OpenGLES 2.0 : gl_VertexID equivalent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10044185/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com