顶点着色器处理后我需要得到 4 个顶点。具有目标的原始(四边形)绘图:GL_TRIANGLE_STRIP。
我的代码:
layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 4) out;
in vs_output
{
vec4 color;
} gs_in[];
out gs_output
{
vec2 st ;
vec4 color;
} gs_out;
void main()
{
gl_Position = gl_in[0].gl_Position;
gs_out.st = vec2(0.0f, 0.0f);
gs_out.color = gs_in[0].color;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
gs_out.st = vec2(0.0f, 1.0f);
gs_out.color = gs_in[1].color;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
gs_out.st = vec2(1.0f, 0.0f);
gs_out.color = gs_in[2].color;
EmitVertex();
gl_Position = gl_in[3].gl_Position;
gs_out.st = vec2(1.0f, 1.0f);
gs_out.color = gs_in[3].color;
EmitVertex();
EndPrimitive();
}
编译器抛出错误:“数组索引超出范围”
我如何在几何着色器上获得 4 个顶点?