Work on geometry shader based shadows

This commit is contained in:
2023-03-11 22:59:19 +00:00
parent 5724a0543e
commit 7ee3f6581d
18 changed files with 235 additions and 144 deletions
+12 -12
View File
@@ -1,5 +1,6 @@
#version 450 core
layout (lines_adjacency) in;
layout (invocations = 20) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (std140, binding = 1) uniform LightsBlock
@@ -7,9 +8,8 @@ layout (std140, binding = 1) uniform LightsBlock
vec4 posBool[20];
vec4 colRad[20];
} ;
uniform int lightID;
vec3 lightPos1 = posBool[lightID].xyz;
float theBool = posBool[lightID].w;
vec3 lightPos1 = posBool[gl_InvocationID].xyz;
float theBool = posBool[gl_InvocationID].w;
vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos1)), 1));} ;
vec4 shiftBy (float x,vec4 p) { return (vec4 (lightPos1 + (x*normalize(p.xyz-lightPos1)), 1));} ;
// copied from lighting/cap.geom, should not be changed on its own
@@ -34,7 +34,7 @@ void main()
{
if (theBool == 1){
// float ru2 = radiusUniform * radiusUniform ;
float ru = colRad[lightID].w ;
float ru = colRad[gl_InvocationID].w ;
float ru2 = ru * ru;
vec4 p0 = gl_in[0].gl_Position;
vec4 p1 = gl_in[1].gl_Position;
@@ -59,17 +59,17 @@ void main()
vec4 p3 = shiftNear(p1);
if ( dot(n0 , lightDir) > 0)
{
gl_Position = f(p0); EmitVertex();
gl_Position = f(p1); EmitVertex();
gl_Position = f(p2); EmitVertex();
gl_Position = f(p3); EmitVertex();
gl_Position = f(p0); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p1); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p2); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p3); gl_Layer = gl_InvocationID; EmitVertex();
}
else
{
gl_Position = f(p1); EmitVertex();
gl_Position = f(p0); EmitVertex();
gl_Position = f(p3); EmitVertex();
gl_Position = f(p2); EmitVertex();
gl_Position = f(p1); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p0); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p3); gl_Layer = gl_InvocationID; EmitVertex();
gl_Position = f(p2); gl_Layer = gl_InvocationID; EmitVertex();
}
EndPrimitive();
}