37 lines
870 B
GLSL
37 lines
870 B
GLSL
#version 430 core
|
|
layout (points) in;
|
|
layout (triangle_strip, max_vertices = 4) out;
|
|
|
|
in vec4 vColor [];
|
|
out vec4 gColor;
|
|
out vec2 tPos;
|
|
|
|
uniform mat4 worldMat;
|
|
|
|
// 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()
|
|
{
|
|
gColor = vColor[0];
|
|
|
|
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,-0.3,1);
|
|
vec4 p4 = vec4 (p2.xy,-0.3,1);
|
|
|
|
vec4 a1 = worldMat * p1;
|
|
vec4 a2 = worldMat * p2;
|
|
vec4 a3 = worldMat * p3;
|
|
vec4 a4 = worldMat * p4;
|
|
|
|
tPos = vec2 ( 1,-1) ; gl_Position = a1; EmitVertex();
|
|
tPos = vec2 ( 1, 1) ; gl_Position = a3; EmitVertex();
|
|
tPos = vec2 (-1,-1) ; gl_Position = a2; EmitVertex();
|
|
tPos = vec2 (-1, 1) ; gl_Position = a4; EmitVertex();
|
|
EndPrimitive();
|
|
}
|