#version 450 core layout (points) in; layout (triangle_strip, max_vertices = 4) out; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; in vec2 vTexAng[]; out float gAng; out vec2 tPos; out vec4 gPos; out vec4 gNorm; out vec3 gTexCoords; // consider using isLHS to check if the wall is facing the center float isLHS (vec2 startV, vec2 testV) { return sign( -startV.x * testV.y + startV.y * testV.x); } void main() { gAng = vTexAng[0].y; float tcoordz = vTexAng[0].x; vec2 p1xy = gl_in[0].gl_Position.xy; vec2 p2xy = gl_in[0].gl_Position.zw; vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1); vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1); vec4 p3 = vec4 (p1.xy,100,1); vec4 p4 = vec4 (p2.xy,100,1); vec2 d = vec2(p1.xy - p2.xy); float dist = distance(p1xy,p2xy); float tcoordx = dist / 50; vec4 norm = vec4( d.y, -d.x, 0, 0); gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = vec4(theMat * p1); gNorm = gPos - norm; gTexCoords = vec3 (0,0,tcoordz); EmitVertex(); gPos = p3; tPos = vec2 ( 1, 1) ; gl_Position = vec4(theMat * p3); gNorm = gPos - norm; gTexCoords = vec3 (0,2,tcoordz); EmitVertex(); gPos = p2; tPos = vec2 (-1,-1) ; gl_Position = vec4(theMat * p2); gNorm = gPos - norm; gTexCoords = vec3 (tcoordx,0,tcoordz); EmitVertex(); gPos = p4; tPos = vec2 (-1, 1) ; gl_Position = vec4(theMat * p4); gNorm = gPos - norm; gTexCoords = vec3 (tcoordx,2,tcoordz); EmitVertex(); EndPrimitive(); }