Working (but slow) shadow shapes

This commit is contained in:
2021-09-17 23:12:51 +01:00
parent 294e01479a
commit 6ac53c052c
16 changed files with 167 additions and 60 deletions
+1
View File
@@ -3,6 +3,7 @@ layout (triangles) in;
layout (triangle_strip, max_vertices = 3) out;
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
uniform vec3 lightPos;
// this code is duplicated in lineShadow.geom, should not be changed on its own
vec4 projNear (vec4 pos)
{
// note we project to a specific height
+7 -5
View File
@@ -4,7 +4,7 @@ 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));}
// copied from lighting/cap.geom
// copied from lighting/cap.geom, should not be changed on its own
vec4 projNear (vec4 pos)
{
// note we project to a specific height
@@ -21,13 +21,16 @@ vec4 shiftNear (vec4 pos)
else
{ return sp ; }
}
vec4 f (vec4 p) {return (theMat * p);}
void main()
{
vec4 p0 = gl_in[0].gl_Position;
vec3 n0 = gl_in[2].gl_Position.xyz;
vec3 n1 = gl_in[3].gl_Position.xyz;
vec4 p1 = gl_in[1].gl_Position;
vec3 n0a = gl_in[2].gl_Position.xyz;
vec3 n1a = gl_in[3].gl_Position.xyz;
vec3 n0 = cross(p1.xyz - p0.xyz, n0a - p0.xyz) ;
vec3 n1 = cross(p0.xyz - p1.xyz, n1a - p1.xyz) ;
//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
@@ -35,7 +38,6 @@ void main()
// "different directions" wrt the light direction
if ( dot(n0 , lightDir) * dot(n1 , lightDir) < 0 )
{
vec4 p1 = gl_in[1].gl_Position;
vec4 p2 = shiftNear(p0);
vec4 p3 = shiftNear(p1);
if ( dot(n0 , lightDir) > 0)