Replace explicit matrix uniforms with single ubo

This commit is contained in:
jgk
2021-06-24 17:58:15 +02:00
parent 7ab932db93
commit 97598bc171
26 changed files with 39 additions and 174 deletions
+5 -8
View File
@@ -1,12 +1,9 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
in vec4 vColor [];
out vec4 gColor;
uniform mat4 worldMat;
// consider using isLHS to check if the wall is facing the center
// this needs the view from point
float isLHS (vec2 startV, vec2 testV)
@@ -21,16 +18,16 @@ void main()
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
vec4 a1 = worldMat * p1;
vec4 a2 = worldMat * p2;
vec4 a1 = theMat * p1;
vec4 a2 = theMat * p2;
// if (0 > isLHS (a1.xy - a2.xy, a1.xy - "viewFromPoint")) {
vec4 p3 = vec4 (p1.xy,-0.5,1);
vec4 p4 = vec4 (p2.xy,-0.5,1);
vec4 a3 = worldMat * p3;
vec4 a4 = worldMat * p4;
vec4 a3 = theMat * p3;
vec4 a4 = theMat * p4;
gl_Position = a1; EmitVertex();
gl_Position = a3; EmitVertex();
-2
View File
@@ -1,9 +1,7 @@
#version 430 core
layout (location = 0) in vec4 poss;
layout (location = 1) in vec4 color;
out vec4 vColor;
void main()
{
gl_Position = poss;
-4
View File
@@ -1,13 +1,9 @@
#version 430 core
in vec2 tPos;
in vec4 gColor;
uniform sampler2D tex;
out vec4 fColor;
void main()
{
fColor = gColor * texture(tex,tPos);
// fColor = gColor;
}
+5 -8
View File
@@ -1,13 +1,10 @@
#version 430 core
layout (points) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
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)
{
@@ -23,10 +20,10 @@ 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;
vec4 a1 = theMat * p1;
vec4 a2 = theMat * p2;
vec4 a3 = theMat * p3;
vec4 a4 = theMat * p4;
tPos = vec2 ( 1,-1) ; gl_Position = a1; EmitVertex();
tPos = vec2 ( 1, 1) ; gl_Position = a3; EmitVertex();
-2
View File
@@ -1,9 +1,7 @@
#version 430 core
layout (location = 0) in vec4 poss;
layout (location = 1) in vec4 color;
out vec4 vColor;
void main()
{
gl_Position = poss;