Work on geometry shader based shadows
This commit is contained in:
@@ -9,6 +9,7 @@ layout (std140, binding = 1) uniform LightsBlock
|
||||
} ;
|
||||
uniform int lightID;
|
||||
vec3 lightPos = posBool[lightID].xyz ;
|
||||
float theBool = posBool[gl_InvocationID].w;
|
||||
// this code is duplicated in lineShadow.geom, should not be changed on its own
|
||||
vec4 projNear (vec4 pos)
|
||||
{
|
||||
@@ -29,6 +30,7 @@ void main()
|
||||
( p0.z - lightPos.z > 0 )
|
||||
&& ( p1.z - lightPos.z > 0 )
|
||||
&& ( p2.z - lightPos.z > 0 )
|
||||
&& theBool == 1
|
||||
)
|
||||
{
|
||||
// the front cap
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#version 450 core
|
||||
uniform sampler2DArray screenTexture;
|
||||
in vec3 gTexPos;
|
||||
out vec4 fColor;
|
||||
void main()
|
||||
{
|
||||
fColor = texture(screenTexture,gTexPos);
|
||||
//fColor = vec4(0.05,0.01,0,1);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#version 450 core
|
||||
layout (points) in;
|
||||
layout (triangle_strip, max_vertices = 4) out;
|
||||
layout (invocations = 20) in;
|
||||
layout (std140, binding = 1) uniform LightsBlock
|
||||
{
|
||||
vec4 posBool[20];
|
||||
vec4 colRad[20];
|
||||
} ;
|
||||
out vec3 gTexPos;
|
||||
float theBool = posBool[gl_InvocationID].w;
|
||||
float l = gl_InvocationID;
|
||||
void main()
|
||||
{
|
||||
if (theBool == 1){
|
||||
gTexPos = vec3(0,1,l);
|
||||
gl_Position = vec4(-1,1,0,1) ;
|
||||
EmitVertex();
|
||||
gTexPos = vec3(0,0,l);
|
||||
gl_Position = vec4(-1,-1,0,1) ;
|
||||
EmitVertex();
|
||||
gTexPos = vec3(1,1,l);
|
||||
gl_Position = vec4(1,1,0,1) ;
|
||||
EmitVertex();
|
||||
gTexPos = vec3(1,0,l);
|
||||
gl_Position = vec4(1,-1,0,1) ;
|
||||
EmitVertex();
|
||||
EndPrimitive();
|
||||
}else {}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#version 450 core
|
||||
void main()
|
||||
{
|
||||
}
|
||||
+12
-12
@@ -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();
|
||||
}
|
||||
|
||||
@@ -8,14 +8,15 @@ uniform int lightID;
|
||||
vec3 lightPos = posBool[lightID].xyz;
|
||||
vec4 lumRad = colRad[lightID];
|
||||
uniform sampler2D screenTexture;
|
||||
in vec2 vTexPos;
|
||||
in vec2 gTexPos;
|
||||
out vec4 fColor;
|
||||
void main()
|
||||
{
|
||||
vec3 distVec = texture(screenTexture,vTexPos).xyz - lightPos;
|
||||
vec3 distVec = texture(screenTexture,gTexPos).xyz - lightPos;
|
||||
float dist = dot(distVec,distVec);
|
||||
if (dist > lumRad.a) {discard;}
|
||||
float x = 1 - dist / lumRad.a ;
|
||||
vec3 c = (x * x * x) * lumRad.rgb ;
|
||||
fColor = vec4(c,0);
|
||||
//fColor = vec4(c,0);
|
||||
fColor = vec4(1,0,0,0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#version 450 core
|
||||
layout (triangles) in;
|
||||
layout (triangle_strip, max_vertices = 3) out;
|
||||
layout (invocations = 20) in;
|
||||
layout (std140, binding = 1) uniform LightsBlock
|
||||
{
|
||||
vec4 posBool[20];
|
||||
vec4 colRad[20];
|
||||
} ;
|
||||
float theBool = posBool[gl_InvocationID].w;
|
||||
in vec2 vTexPos[];
|
||||
out vec2 gTexPos;
|
||||
void main()
|
||||
{
|
||||
if (theBool == 1){
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
gTexPos = vTexPos[i];
|
||||
gl_Layer = gl_InvocationID;
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}else {}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 450 core
|
||||
layout (points) in;
|
||||
layout (invocations = 20) in;
|
||||
layout (triangle_strip, max_vertices = 8) out;
|
||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||
layout (std140, binding = 1) uniform LightsBlock
|
||||
@@ -7,8 +8,8 @@ layout (std140, binding = 1) uniform LightsBlock
|
||||
vec4 posBool[20];
|
||||
vec4 colRad[20];
|
||||
} ;
|
||||
uniform int lightID;
|
||||
vec3 lightPos = posBool[lightID].xyz;
|
||||
vec3 lightPos = posBool[gl_InvocationID].xyz;
|
||||
float theBool = posBool[gl_InvocationID].w;
|
||||
vec4 shift (vec4 p)
|
||||
{ return vec4 (p.xy + (200 * (p.xy-lightPos.xy)), 0 , 1);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ void main()
|
||||
{
|
||||
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
||||
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
|
||||
if (isLHS (p1.xy - lightPos.xy, p2.xy - lightPos.xy) < 0)
|
||||
if (theBool==1 && isLHS (p1.xy - lightPos.xy, p2.xy - lightPos.xy) < 0)
|
||||
{
|
||||
vec4 p3 = vec4 (p1.xy,100,1);
|
||||
vec4 p4 = vec4 (p2.xy,100,1);
|
||||
@@ -39,35 +40,14 @@ vec4 a6 = theMat * p6;
|
||||
vec4 a7 = theMat * p7;
|
||||
vec4 a8 = theMat * p8;
|
||||
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a8; EmitVertex();
|
||||
//gl_Position = a5; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a1; EmitVertex();
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a2; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a6; EmitVertex();
|
||||
|
||||
gl_Position = a1; EmitVertex();
|
||||
gl_Position = a5; EmitVertex();
|
||||
gl_Position = a3; EmitVertex();
|
||||
gl_Position = a8; EmitVertex();
|
||||
gl_Position = a4; EmitVertex();
|
||||
gl_Position = a7; EmitVertex();
|
||||
gl_Position = a2; EmitVertex();
|
||||
gl_Position = a6; EmitVertex();
|
||||
|
||||
//gl_Position = a5; EmitVertex();
|
||||
//gl_Position = a1; EmitVertex();
|
||||
//gl_Position = a8; EmitVertex();
|
||||
//gl_Position = a3; EmitVertex();
|
||||
//gl_Position = a7; EmitVertex();
|
||||
//gl_Position = a4; EmitVertex();
|
||||
//gl_Position = a6; EmitVertex();
|
||||
//gl_Position = a2; EmitVertex();
|
||||
gl_Position = a1; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a5; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a3; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a8; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a4; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a7; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a2; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
gl_Position = a6; gl_Layer = gl_InvocationID; EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
} else {}
|
||||
|
||||
Reference in New Issue
Block a user