GLSL geometry shader using lines_adjacency
-
28-05-2021 - |
سؤال
I am writing a GLSL geometry shader and I am trying to use the lines_adjacency
input layout but it isn't working. My first pass-though test using the lines
input layout works fine:
// GLSL GEOMETRY SHADER
#version 410
layout (lines) in;
layout (line_strip, max_vertices = 2) out;
void main ()
{
gl_Position = gl_in[0].gl_Position;
EmitVertex();
gl_Position = gl_in[1].gl_Position;
EmitVertex();
EndPrimitive();
}
but when I switch to lines_adjacency
input it doesn't draw anything:
// GLSL GEOMETRY SHADER
#version 410
layout (lines_adjacency) in;
layout (line_strip, max_vertices = 2) out;
void main ()
{
gl_Position = gl_in[1].gl_Position;
EmitVertex();
gl_Position = gl_in[2].gl_Position;
EmitVertex();
EndPrimitive();
}
I know I'm not actually using the adjacency points here but I will need them eventually. I am a GLSL novice so any help would be appreciated, thanks.
المحلول
You did change your input vertices to provide adjacency data, right? Because OpenGL doesn't parse your vertex data to figure out what is adjacent to what. The adjacency types exist to allow you to tell the shader about adjacent info. So you must provide that data.
In short, you can't render with the exact same attributes and index data with an adjacency geometry shader. Nevermind the fact that your glDraw*
calls need to use GL_LINES_ADJACENCY
instead of GL_LINES
.