Remove unnecessary uniforms

This commit is contained in:
jgk
2021-06-10 18:07:26 +02:00
parent 95f8e57e45
commit 02511afa80
10 changed files with 69 additions and 93 deletions
+9 -48
View File
@@ -3,11 +3,9 @@ layout (points) in;
layout (triangle_strip, max_vertices = 11) out;
uniform vec2 lightPos;
uniform mat4 perpMat;
uniform mat4 worldMat;
uniform float facesToDraw;
vec2 lightPosa = ( perpMat * vec4(lightPos,0,1) ).xy;
vec2 lightPosa = ( worldMat * vec4(lightPos,0,1) ).xy;
vec4 shift (vec4 p)
{ return vec4 (p.xy + (200 * (p.xy-lightPos)), 0 , 1);
@@ -30,19 +28,14 @@ vec4 p6 = shift(p2);
vec4 p7 = vec4 (p6.xy,-0.5,1);
vec4 p8 = vec4 (p5.xy,-0.5,1);
vec4 a1 = perpMat * p1;
vec4 a2 = perpMat * p2;
vec4 a3 = perpMat * p3;
vec4 a4 = perpMat * p4;
vec4 a5 = perpMat * p5;
vec4 a6 = perpMat * p6;
vec4 a7 = perpMat * p7;
vec4 a8 = perpMat * p8;
// gl_Position = a1; EmitVertex();
// gl_Position = a5; EmitVertex();
// gl_Position = a2; EmitVertex();
// gl_Position = a6; EmitVertex();
vec4 a1 = worldMat * p1;
vec4 a2 = worldMat * p2;
vec4 a3 = worldMat * p3;
vec4 a4 = worldMat * p4;
vec4 a5 = worldMat * p5;
vec4 a6 = worldMat * p6;
vec4 a7 = worldMat * p7;
vec4 a8 = worldMat * p8;
gl_Position = a4; EmitVertex();
gl_Position = a3; EmitVertex();
@@ -59,35 +52,3 @@ vec4 a8 = perpMat * p8;
EndPrimitive();
} else {}
}
// // void main()
// // {
// // vec4 frontL4 = worldMat * vec4(gl_in[0].gl_Position.xy, 0 ,1);
// // vec4 frontR4 = worldMat * vec4(gl_in[0].gl_Position.zw, 0 ,1);
// // vec2 frontL = frontL4.xy;
// // vec2 frontR = frontR4.xy;
// //
// // emitLine (frontR);
// // emitLine (frontL);
// // EndPrimitive();
// // }
// gl_Position = perspective * worldMat * p4; EmitVertex();
// gl_Position = perspective * worldMat * p3; EmitVertex();
// gl_Position = perspective * worldMat * p7; EmitVertex();
// gl_Position = perspective * worldMat * p8; EmitVertex();
// gl_Position = perspective * worldMat * p5; EmitVertex();
// gl_Position = perspective * worldMat * p3; EmitVertex();
// gl_Position = perspective * worldMat * p1; EmitVertex();
// gl_Position = perspective * worldMat * p4; EmitVertex();
// gl_Position = perspective * worldMat * p2; EmitVertex();
// gl_Position = perspective * worldMat * p7; EmitVertex();
// gl_Position = perspective * worldMat * p6; EmitVertex();
// gl_Position = perspective * worldMat * p5; EmitVertex();
//void emitLine (vec2 pa)
//{
// gl_Position = vec4 (pa, 0, 1);
// EmitVertex();
// gl_Position = shift (vec4 (pa,0,1)); //vec4 (pa + (200 * (pa - lightPosa)), 0 , 1);
// EmitVertex();
//}
+5 -5
View File
@@ -6,7 +6,7 @@ out vec3 dField;
out float lum;
uniform vec2 lightPos;
uniform mat4 perpMat;
uniform mat4 worldMat;
uniform vec2 radLum;
float isLHS (vec2 startV, vec2 testV)
@@ -31,10 +31,10 @@ if (isLHS (p1.xy - lightPos, p2.xy - lightPos) < 0)
vec2 d1 = p1.xy - lightPos;
vec2 d2 = p2.xy - lightPos;
vec4 a1 = shiftCloser( perpMat * p1 );
vec4 a2 = shiftCloser( perpMat * p2 );
vec4 a3 = shiftCloser( perpMat * p3 );
vec4 a4 = shiftCloser( perpMat * p4 );
vec4 a1 = shiftCloser( worldMat * p1 );
vec4 a2 = shiftCloser( worldMat * p2 );
vec4 a3 = shiftCloser( worldMat * p3 );
vec4 a4 = shiftCloser( worldMat * p4 );
dField = vec3( d1.x/rad, d1.y/rad, 0);
gl_Position = a1;
+5 -5
View File
@@ -5,7 +5,7 @@ layout (triangle_strip, max_vertices = 4) out;
in vec4 vColor [];
out vec4 gColor;
uniform mat4 perpMat;
uniform mat4 worldMat;
// consider using isLHS to check if the wall is facing the center
// this needs the view from point
@@ -21,16 +21,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 = perpMat * p1;
vec4 a2 = perpMat * p2;
vec4 a1 = worldMat * p1;
vec4 a2 = worldMat * 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 = perpMat * p3;
vec4 a4 = perpMat * p4;
vec4 a3 = worldMat * p3;
vec4 a4 = worldMat * p4;
gl_Position = a1; EmitVertex();
gl_Position = a3; EmitVertex();
+5 -5
View File
@@ -6,7 +6,7 @@ in vec4 vColor [];
out vec4 gColor;
out vec2 tPos;
uniform mat4 perpMat;
uniform mat4 worldMat;
// consider using isLHS to check if the wall is facing the center
float isLHS (vec2 startV, vec2 testV)
@@ -23,10 +23,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 = perpMat * p1;
vec4 a2 = perpMat * p2;
vec4 a3 = perpMat * p3;
vec4 a4 = perpMat * p4;
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();