Draw walls using perspective divide

This commit is contained in:
jgk
2021-03-18 12:58:17 +01:00
parent e98e7256d2
commit 447268117c
5 changed files with 80 additions and 17 deletions
+9
View File
@@ -0,0 +1,9 @@
#version 430 core
in vec4 vParams;
out vec4 fColor;
void main()
{
fColor = vec4 (0.9,0.5,0,1);
fColor = vParams;
}
+31
View File
@@ -0,0 +1,31 @@
#version 430 core
layout (triangles) in;
layout (triangle_strip, max_vertices = 4) out;
in vec4 vParams[];
uniform mat4 worldMat;
vec2 lightPos = gl_in[0].gl_Position.xy;
vec2 cornerA = gl_in[1].gl_Position.xy;
vec2 cornerB = gl_in[2].gl_Position.xy;
void main()
{
gl_Position = worldMat * vec4(cornerA, 1, 1 );
EmitVertex();
gl_Position = worldMat * (vec4(cornerA, 10, 1 ) + (20,20,0,0));
gl_Position = vec4(1,0, 10, 1 );
EmitVertex();
gl_Position = worldMat * vec4(cornerB, 0, 1 );
gl_Position = vec4(0,1, -10, 1 );
EmitVertex();
gl_Position = worldMat * (vec4(cornerB, 0, 1 ) + (20,20,0,0));
gl_Position = vec4(1,1, 10, 1 );
EmitVertex();
EndPrimitive();
}
+18
View File
@@ -0,0 +1,18 @@
#version 430 core
layout (location = 0) in vec3 pos;
layout (location = 1) in vec4 params;
out vec4 vParams;
uniform mat4 worldMat;
mat4 perspective =
mat4 (1,0,0,0
,0,1,0,0
,0,0,1,1
,0,0,0,1
) ;
void main()
{
gl_Position = perspective * worldMat * vec4(pos.xyz, 1);
vParams = params;
}