Hi all,
I have been messing about with a geometry shader in GLSL and something strange is going on.
Basically, I was playing about with texturing the a model. Normally (just a vert and frag shader), its just a case of in the vert shader…
out vec2 TextCoords
then of course set TextCoords
= to the buffer from the VAO.
then take them into the frag shader…
in vec2 TextCoords;
Then use sampler2D
and the glsl texture method.
In actual fact this in itself is quite strange, as the buffer in the VAO holds all the texture coordinates, not simply a vec2 as declared, to me this should if anything give me the first pair of texture coordinates. I am presuming something is going on in the background.
So, to the geometry shader, this is where things get strange. When I add in a geometry shader that is exactly what happens, I only get a single coordinate, and therefore a single colour from the texture. This is fixed using interface blocks, the code then becomes,
in the vert…
out VS_OUT{
vec2 texCoords;
} vs_out;
in the geom…
in VS_OUT {
vec2 texCoords;
} gs_in[];
in the frag…
in vec2 TexCoords;
This is really quite baffling for someone who is new to GLSL, in fact the only on that makes sense to me from a programming perspective is…
in VS_OUT {
vec2 texCoords;
} gs_in[];
as after all I am saving the buffer from my VAO into an array of vec2
. So why don’t I need to use arrays all the time, and why do I need to use them when I add in the geom shader?
Thanks for any help.