Fix wall normals

This commit is contained in:
2023-03-16 23:31:17 +00:00
parent 100fdc102d
commit 539cbe8b18
11 changed files with 32 additions and 46 deletions
+2 -1
View File
@@ -4,11 +4,12 @@ layout (location=1) out vec4 fPos;
layout (location=2) out vec4 fNorm;
in vec2 tPos;
in vec4 gPos;
in vec4 gNorm;
in vec4 gColor;
uniform sampler2D tex;
void main()
{
fCol = gColor * texture(tex,tPos);
fPos = gPos;
fNorm = gPos + vec4(1,0,0,0);
fNorm = gNorm;
}
+7
View File
@@ -6,6 +6,7 @@ in vec4 vColor [];
out vec4 gColor;
out vec2 tPos;
out vec4 gPos;
out vec4 gNorm;
// 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); }
@@ -15,9 +16,15 @@ void main()
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);
vec4 norm = vec4( d.y, -d.x, 0, 1);
gNorm = p1 - norm;
gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = vec4(theMat * p1); EmitVertex();
gNorm = p1 - norm;
gPos = p3; tPos = vec2 ( 1, 1) ; gl_Position = vec4(theMat * p3); EmitVertex();
gNorm = p1 - norm;
gPos = p2; tPos = vec2 (-1,-1) ; gl_Position = vec4(theMat * p2); EmitVertex();
gNorm = p1 - norm;
gPos = p4; tPos = vec2 (-1, 1) ; gl_Position = vec4(theMat * p4); EmitVertex();
EndPrimitive();
}