Asonic84
Asonic84

Reputation: 79

unable to link geometry shader properly

I am trying to create a simple passthrough "Geometry Shader" but for some reason its not linking. Debug info says its compiling fine.I don't know what I am doing wrong in this one? It is not the drivers or OS as I have linked and used geometry shader before, and they worked fine.

Vertex Shader code:

#version 450

in vec3 position;
uniform mat4 MVP;
out vec4 color;

void main()
{
    gl_Position = MVP * vec4(position, 1.0);
    color = vec4(0.5, 0.5, 0.0, 1.0);
}

Fragment Shader code:

#version 450

in vec4 fColor;
out vec4 fcolor;

void main() {
    fcolor = fColor;
}

Geometry Shader Code:

#version 450

layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;

in vec4 color;
out vec4 fColor;

void main()
{
    fColor = color;
    for(int i = 0; i <= gl_in.length(); i++)
    {
        gl_Position = gl_in[i].gl_Position;
        EmitVertex();
    }
    EndPrimitive();
}

Debug output:

In Compile Shader from file: ../Curve.vert compile result:: 1 Shader compile and attach success: In Compile Shader from file: ../Curve.geom compile result:: 1 Shader compile and attach success: In Compile Shader from file: ../Curve.frag compile result:: 1 Shader compile and attach success: Linking.. , Program handle found: 1 GL Renderer : GeForce GTX 1660 Ti/PCIe/SSE2 GL Vendor : NVIDIA Corporation GL Version : 4.6.0 NVIDIA 461.40 GL Version No. : 4.6 GLSL Version : 4.60 NVIDIA --------------- Debug message (131216): Program/shader state info: GLSL program 1 failed to link Source: API Type: Other Severity: low

Curve shader program not linked Curve shader program not validated Use unsuccessful, returning? m_linked status: false Program handle: 1 Curve shader program handle: 1

Upvotes: 1

Views: 459

Answers (1)

Rabbid76
Rabbid76

Reputation: 211230

The Geometry Shader transforms Primitives and is executed for each primitive. Therefore, the input of the Geometry Shader is an array the size of the vertex number of the primitives. e.g.:

in vec4 color[];

You have to emit a vertex for each vertex of the output primitive.

Upvotes: 1

Related Questions