Commit before attempt to remove geometry shaders from shadow extrusion

This commit is contained in:
2023-02-23 23:10:00 +00:00
parent f98f95d92f
commit c73e8af72a
15 changed files with 28 additions and 31 deletions
+3 -8
View File
@@ -18,24 +18,19 @@ void main()
vec4 p0 = gl_in[0].gl_Position ;
vec4 p1 = gl_in[1].gl_Position ;
vec4 p2 = gl_in[2].gl_Position ;
if ( //dot( p0.xyz - vec3 (0,0,1), cross( p0.xyz - p1.xyz, p1.xyz - p2.xyz)) < 0
// &&
if ( //if Light Source is below all vertices, draw cap
// TODO think about when LS is beside the object
( p0.z - lightPos.z > 0 )
&& ( p1.z - lightPos.z > 0 )
&& ( p2.z - lightPos.z > 0 )
)
{
// front cap
// the front cap
vec4 v1 = vec4 (0,0,1,0) ;
gl_Position = theMat * projNear(p0); EmitVertex();
gl_Position = theMat * projNear(p1); EmitVertex();
gl_Position = theMat * projNear(p2); EmitVertex();
EndPrimitive();
// if light points downwards onto surface, draw back cap too
if (dot ( p0.xyz - lightPos, vec3 ( 0,0,1) ) > 0)
{
}
else {}
}
else {}
}
+3 -2
View File
@@ -3,7 +3,8 @@ layout (lines_adjacency) in;
layout (triangle_strip, max_vertices = 4) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));}
//vec4 shift (vec4 p) { return (vec4 (p.xyz + (100000*(p.xyz-lightPos)), 1));}
vec4 shift (vec4 p) { return (vec4 (p.xyz + (1000*(p.xyz-lightPos)), 1));}
// copied from lighting/cap.geom, should not be changed on its own
vec4 projNear (vec4 pos)
{
@@ -34,7 +35,7 @@ void main()
//vec3 n2 = n0 + n1; // assumes the summands are normalized
vec3 lightDir = p0.xyz - lightPos.xyz;
// first test if the edge is part of the silhouette
// that is, if the normals of the faces connected by the edge point in
// that is, if the normals of the faces connected by the edge point are in
// "different directions" wrt the light direction
if ( dot(n0 , lightDir) * dot(n1 , lightDir) <= 0 )
// using <= rather than < seems to get rid of overlapping shadow