So I am currently using a geometry shader in an attempt to create textured squares for my particle system , however they appear to have an extremely odd effect when I generate them and instead of just creating two triangle_strips they fill the right side of the screen with triangles aswell. I am baffled as everything looks right to me help would be appreciated.
Here is what happens
Here is my vert shader code:
uniform float alpha;
uniform float time;
uniform vec2 spawn;
uniform float decay;
uniform vec2 dimension;
uniform float size;
attribute vec3 vecin;
attribute vec2 texin;
void main(){
float x_move,y_move;
x_move = ((time * (vecin.x - spawn.x)) - ((((time-decay)/10000) * (time) * (vecin.x - spawn.x))) );
y_move = ((time * (vecin.y - spawn.y)) - ((((time-decay)/10000) * (time) * (vecin.y - spawn.y))) );
x_move/= 10000;
y_move/= 10000;
gl_Position = vec4(vecin.x + x_move,vecin.y + y_move,texin.x,texin.y);
}
Geometry shader
#version 330
//uses an 8 by 8 spritesheet make sure you use it!
layout (points) in;
layout (triangle_strip) out;
layout (max_vertices = 4) out;
uniform vec2 dimension;
uniform float size;
out vec2 texcoord;
void main(){
vec2 size_adjust = vec2(size/dimension.x,size/dimension.y);
float eigth = (1/8);
gl_Position = vec4(gl_in[0].gl_Position.x,gl_in[0].gl_Position.y,1,1);
texcoord = vec2(gl_in[0].gl_Position.z,gl_in[0].gl_Position.w + eigth);
EmitVertex();
gl_Position = vec4(gl_in[0].gl_Position.x,gl_in[0].gl_Position.y + size_adjust.y,1,1);
texcoord = vec2(gl_in[0].gl_Position.z,gl_in[0].gl_Position.w);
EmitVertex();
gl_Position = vec4(gl_in[0].gl_Position.x + size_adjust.x,gl_in[0].gl_Position.y,1,1);
texcoord = vec2(gl_in[0].gl_Position.z + (1/8),gl_in[0].gl_Position.w + (1/8));
EmitVertex();
gl_Position = vec4(gl_in[0].gl_Position.x + size_adjust.x,gl_in[0].gl_Position.y + size_adjust.y,1,1);
texcoord = vec2(gl_in[0].gl_Position.z + eigth,gl_in[0].gl_Position.w);
EmitVertex();
EndPrimitive();
}
and my frag shader
uniform sampler2D texture;
uniform float alpha;
in vec2 texcoord;
void main(){
gl_FragColor = vec4(texture2D(texture,texcoord).rgb,alpha);
}
Thanks.