0
votes

So I have three shaders in my program.

Vertex:

#version 330 core
in vec2 Inpoint;
in vec2 texCoords;

out vec2 TexCoords;

uniform mat4 model;
uniform mat4 projection;

void main()
{
    TexCoords = texCoords;
    gl_Position = projection * model * vec4(Inpoint, 0.0, 1.0);
}

Geometry:

#version 330 core

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

void main()
{
    int i;

    for (i = 0; i < gl_in.length(); i++)
    {
        gl_Position = gl_in[i].gl_Position;
        EmitVertex();
    }
    EndPrimitive();
}

And finally the fragment shader:

#version 330 core
in vec2 TexCoords;
out vec4 color;

uniform sampler2D image;
uniform vec3 spriteColor;

void main()
{    
    color = vec4(spriteColor, 1.0) * texture(image, TexCoords);
}  

Now without the geometry shader, everything displays just fine. But as soon as I include the geometry shader, everything goes ... bad.

It acts like its not getting chords for the textures.

So, the question is, does the geometry shader need to pass the data through itself to the fragment shader? I mean the geometry shader is basically doing nothing so it shouldn't. Unless there is some giant mistake I am missing.

I tried to add a pass-though but it complains that everything needs to be an array, and even when I did make it an array it didn't quite work right.

1

1 Answers

4
votes

Quoting GLSL 3.30 specs 4.3.1 Inputs :

Fragment shader inputs get per-fragment values, typically interpolated from a previous stage's outputs

Having a geometry shader is the previous stage. So yes, your FS uses inputs from your GS and only from it.