My goal is to render a sine wave in 3D space. The wave would be made up of small line segments. So I have a vertex shader that passes the points of the waves as lines to my geometry shader.
The geometry shader takes the two vertices in each line segment and uses them to draw two triangles. This allows me to adjust the thickness of the wave in the z direction.
My geometry shader is set up this way:
layout (lines, invocations = WAVES_PER_GROUP) in;
layout (triangle_strip, max_vertices = 4) out;
And this is the core code:
float th = 0.1;
vec4 quadCL = gl_in[0].gl_Position;
vec4 quadCR = gl_in[1].gl_Position;
vec4 quadTL = quadCL + vec4(0.0,0.0,-th,0.0);
vec4 quadTR = quadCR + vec4(0.0,0.0,-th,0.0);
vec4 quadBL = quadCL + vec4(0.0,0.0,th,0.0);
vec4 quadBR = quadCR + vec4(0.0,0.0,th,0.0);
//Push the quad
//Quad
//0: TL
gl_Position = quadTL;
EmitVertex();
//1: BL
gl_Position = quadBL;
EmitVertex();
//2: TR
gl_Position = quadTR;
EmitVertex();
//3: BR
gl_Position = quadBR;
EmitVertex();
EndPrimitive();
I've made sure the all my position variables have a w value of 1.0. I'm getting what seems to be some kind of clipping in the z direction. If this is the right approach, then I will need to troubleshoot other parts of my code.
I would appreciate thoughts &&|| prayers on this.
Cheers!