Add alternate shadow volume rendering pathway (layered geo)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout (triangles) in;
|
layout (triangles) in;
|
||||||
|
layout (invocations = 20) in;
|
||||||
layout (triangle_strip, max_vertices = 3) out;
|
layout (triangle_strip, max_vertices = 3) out;
|
||||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||||
layout (std140, binding = 1) uniform LightsBlock
|
layout (std140, binding = 1) uniform LightsBlock
|
||||||
@@ -7,8 +8,7 @@ layout (std140, binding = 1) uniform LightsBlock
|
|||||||
vec4 posBool[20];
|
vec4 posBool[20];
|
||||||
vec4 colRad[20];
|
vec4 colRad[20];
|
||||||
} ;
|
} ;
|
||||||
uniform int lightID;
|
vec3 lightPos = posBool[gl_InvocationID].xyz ;
|
||||||
vec3 lightPos = posBool[lightID].xyz ;
|
|
||||||
float theBool = posBool[gl_InvocationID].w;
|
float theBool = posBool[gl_InvocationID].w;
|
||||||
// this code is duplicated in lineShadow.geom, should not be changed on its own
|
// this code is duplicated in lineShadow.geom, should not be changed on its own
|
||||||
vec4 projNear (vec4 pos)
|
vec4 projNear (vec4 pos)
|
||||||
@@ -35,8 +35,11 @@ void main()
|
|||||||
{
|
{
|
||||||
// the front cap
|
// the front cap
|
||||||
vec4 v1 = vec4 (0,0,1,0) ;
|
vec4 v1 = vec4 (0,0,1,0) ;
|
||||||
|
gl_Layer = gl_InvocationID;
|
||||||
gl_Position = theMat * projNear(p0); EmitVertex();
|
gl_Position = theMat * projNear(p0); EmitVertex();
|
||||||
|
gl_Layer = gl_InvocationID;
|
||||||
gl_Position = theMat * projNear(p1); EmitVertex();
|
gl_Position = theMat * projNear(p1); EmitVertex();
|
||||||
|
gl_Layer = gl_InvocationID;
|
||||||
gl_Position = theMat * projNear(p2); EmitVertex();
|
gl_Position = theMat * projNear(p2); EmitVertex();
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout (location = 0) in vec3 position;
|
layout (location = 0) in vec3 position;
|
||||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||||
uniform vec3 lightPos;
|
|
||||||
uniform vec4 lumRad;
|
|
||||||
out vec3 dField;
|
|
||||||
out vec3 lum;
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(position,1);
|
gl_Position = vec4(position,1);
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ layout (std140, binding = 1) uniform LightsBlock
|
|||||||
vec4 posBool[20];
|
vec4 posBool[20];
|
||||||
vec4 colRad[20];
|
vec4 colRad[20];
|
||||||
} ;
|
} ;
|
||||||
uniform int lightID;
|
//uniform int lightID;
|
||||||
vec3 lightPos = posBool[lightID].xyz;
|
vec3 lightPos = posBool[gl_Layer].xyz;
|
||||||
vec4 lumRad = colRad[lightID];
|
vec4 lumRad = colRad[gl_Layer];
|
||||||
uniform sampler2D screenTexture;
|
uniform sampler2D screenTexture;
|
||||||
in vec2 gTexPos;
|
in vec2 gTexPos;
|
||||||
out vec4 fColor;
|
out vec4 fColor;
|
||||||
@@ -17,6 +17,6 @@ void main()
|
|||||||
if (dist > lumRad.a) {discard;}
|
if (dist > lumRad.a) {discard;}
|
||||||
float x = 1 - dist / lumRad.a ;
|
float x = 1 - dist / lumRad.a ;
|
||||||
vec3 c = (x * x * x) * lumRad.rgb ;
|
vec3 c = (x * x * x) * lumRad.rgb ;
|
||||||
//fColor = vec4(c,0);
|
fColor = vec4(c,0);
|
||||||
fColor = vec4(1,0,0,0);
|
//fColor = vec4(0.05,0,0,0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout (triangles) in;
|
layout (points) in;
|
||||||
layout (triangle_strip, max_vertices = 3) out;
|
layout (triangle_strip, max_vertices = 4) out;
|
||||||
layout (invocations = 20) in;
|
layout (invocations = 20) in;
|
||||||
layout (std140, binding = 1) uniform LightsBlock
|
layout (std140, binding = 1) uniform LightsBlock
|
||||||
{
|
{
|
||||||
@@ -8,18 +8,26 @@ layout (std140, binding = 1) uniform LightsBlock
|
|||||||
vec4 colRad[20];
|
vec4 colRad[20];
|
||||||
} ;
|
} ;
|
||||||
float theBool = posBool[gl_InvocationID].w;
|
float theBool = posBool[gl_InvocationID].w;
|
||||||
in vec2 vTexPos[];
|
|
||||||
out vec2 gTexPos;
|
out vec2 gTexPos;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
if (theBool == 1){
|
if (theBool == 1){
|
||||||
for (int i = 0; i < 3; i++)
|
gTexPos = vec2(0,1);
|
||||||
{
|
gl_Position = vec4(-1,1,0,1) ;
|
||||||
gTexPos = vTexPos[i];
|
gl_Layer = gl_InvocationID;
|
||||||
|
EmitVertex();
|
||||||
|
gTexPos = vec2(0,0);
|
||||||
|
gl_Position = vec4(-1,-1,0,1) ;
|
||||||
|
gl_Layer = gl_InvocationID;
|
||||||
|
EmitVertex();
|
||||||
|
gTexPos = vec2(1,1);
|
||||||
|
gl_Position = vec4(1,1,0,1) ;
|
||||||
|
gl_Layer = gl_InvocationID;
|
||||||
|
EmitVertex();
|
||||||
|
gTexPos = vec2(1,0);
|
||||||
|
gl_Position = vec4(1,-1,0,1) ;
|
||||||
gl_Layer = gl_InvocationID;
|
gl_Layer = gl_InvocationID;
|
||||||
gl_Position = gl_in[i].gl_Position;
|
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
}
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}else {}
|
}else {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
#version 450 core
|
#version 450 core
|
||||||
layout (location = 0) in vec2 pos;
|
|
||||||
layout (location = 1) in vec2 texPos;
|
|
||||||
out vec2 vTexPos;
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = vec4(pos,0,1);
|
|
||||||
vTexPos = texPos;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -149,7 +149,7 @@ preloadRender = do
|
|||||||
[1] 1
|
[1] 1
|
||||||
EPoints
|
EPoints
|
||||||
shadowcombineshader <- makeShaderSized "shadow/combine" [vert,geom,frag] [1] 1 EPoints
|
shadowcombineshader <- makeShaderSized "shadow/combine" [vert,geom,frag] [1] 1 EPoints
|
||||||
pokeArray (shadVBOptr' shadowlightshader) $ concat cornerListForTriangles
|
poke (shadVBOptr' shadowlightshader) 1
|
||||||
|
|
||||||
-- positional shader
|
-- positional shader
|
||||||
positionalBlankShad <- makeShader "positional/blank" [vert, frag] [3] ETriangles
|
positionalBlankShad <- makeShader "positional/blank" [vert, frag] [3] ETriangles
|
||||||
@@ -291,15 +291,15 @@ cornerList =
|
|||||||
, [1, 1, 1, 1]
|
, [1, 1, 1, 1]
|
||||||
, [1, -1, 1, 0]
|
, [1, -1, 1, 0]
|
||||||
]
|
]
|
||||||
cornerListForTriangles :: [[Float]]
|
--cornerListForTriangles :: [[Float]]
|
||||||
cornerListForTriangles =
|
--cornerListForTriangles =
|
||||||
[ [-1, 1, 0, 1]
|
-- [ [-1, 1, 0, 1]
|
||||||
, [-1, -1, 0, 0]
|
-- , [-1, -1, 0, 0]
|
||||||
, [1, 1, 1, 1]
|
-- , [1, 1, 1, 1]
|
||||||
, [-1, -1, 0, 0]
|
-- , [-1, -1, 0, 0]
|
||||||
, [1, 1, 1, 1]
|
-- , [1, 1, 1, 1]
|
||||||
, [1, -1, 1, 0]
|
-- , [1, -1, 1, 0]
|
||||||
]
|
-- ]
|
||||||
|
|
||||||
cleanUpRenderPreload :: RenderData -> IO ()
|
cleanUpRenderPreload :: RenderData -> IO ()
|
||||||
cleanUpRenderPreload pd = do
|
cleanUpRenderPreload pd = do
|
||||||
|
|||||||
+16
-19
@@ -199,36 +199,33 @@ instanceLightMap cfig pdata lightPoints nWalls nSils nCaps toPos = do
|
|||||||
--draw wall shadows
|
--draw wall shadows
|
||||||
glUseProgram (_shadProg' lwallShad)
|
glUseProgram (_shadProg' lwallShad)
|
||||||
glBindVertexArray $ lwallShad ^. shadVAO' . vaoName -- Just (_vao $ _shadVAO lwallShad)
|
glBindVertexArray $ lwallShad ^. shadVAO' . vaoName -- Just (_vao $ _shadVAO lwallShad)
|
||||||
-- glDrawArrays
|
glDrawArrays
|
||||||
-- (marshalEPrimitiveMode $ _shadPrim' lwallShad)
|
(marshalEPrimitiveMode $ _shadPrim' lwallShad)
|
||||||
-- 0
|
0
|
||||||
-- (fromIntegral nWalls)
|
(fromIntegral nWalls)
|
||||||
--draw silhouette shadows
|
--draw silhouette shadows
|
||||||
glUseProgram (_shadProg' llinesShad)
|
glUseProgram (_shadProg' llinesShad)
|
||||||
glBindVertexArray (_vaoName $ _shadVAO' llinesShad)
|
glBindVertexArray (_vaoName $ _shadVAO' llinesShad)
|
||||||
-- glDrawElements
|
glDrawElements
|
||||||
-- (marshalEPrimitiveMode $ _shadPrim' llinesShad)
|
(marshalEPrimitiveMode $ _shadPrim' llinesShad)
|
||||||
-- (fromIntegral nSils)
|
(fromIntegral nSils)
|
||||||
-- GL_UNSIGNED_SHORT
|
GL_UNSIGNED_SHORT
|
||||||
-- nullPtr
|
nullPtr
|
||||||
--draw caps on the near plane as required
|
--draw caps on the near plane as required
|
||||||
glEnable GL_CULL_FACE
|
glEnable GL_CULL_FACE
|
||||||
glCullFace GL_BACK
|
glCullFace GL_BACK
|
||||||
glUseProgram (_shadProg' lcapShad)
|
glUseProgram (_shadProg' lcapShad)
|
||||||
glBindVertexArray $ lcapShad ^. shadVAO' . vaoName --Just (_vao $ _shadVAO lcapShad)
|
glBindVertexArray $ lcapShad ^. shadVAO' . vaoName --Just (_vao $ _shadVAO lcapShad)
|
||||||
-- glDrawElements
|
glDrawElements
|
||||||
-- (marshalEPrimitiveMode $ _shadPrim' lcapShad)
|
(marshalEPrimitiveMode $ _shadPrim' lcapShad)
|
||||||
-- (fromIntegral nCaps)
|
(fromIntegral nCaps)
|
||||||
-- GL_UNSIGNED_SHORT
|
GL_UNSIGNED_SHORT
|
||||||
-- nullPtr
|
nullPtr
|
||||||
-- --draw lightmap itself
|
--draw lightmap itself
|
||||||
glEnable GL_DEPTH_TEST
|
glEnable GL_DEPTH_TEST
|
||||||
glDepthFunc GL_ALWAYS
|
glDepthFunc GL_ALWAYS
|
||||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||||
glStencilFunc GL_EQUAL 0 255
|
glStencilFunc GL_EQUAL 0 255
|
||||||
-- delete vvvv
|
|
||||||
glDisable GL_STENCIL_TEST
|
|
||||||
-- delete ^^^^
|
|
||||||
glUseProgram (pdata ^. shadowLightShader . shadProg')
|
glUseProgram (pdata ^. shadowLightShader . shadProg')
|
||||||
-- bind world position texture
|
-- bind world position texture
|
||||||
bindTO toPos
|
bindTO toPos
|
||||||
@@ -237,7 +234,7 @@ instanceLightMap cfig pdata lightPoints nWalls nSils nCaps toPos = do
|
|||||||
glDrawArrays
|
glDrawArrays
|
||||||
(marshalEPrimitiveMode $ pdata ^. shadowLightShader . shadPrim')
|
(marshalEPrimitiveMode $ pdata ^. shadowLightShader . shadPrim')
|
||||||
0
|
0
|
||||||
(fromIntegral (4 :: Int))
|
1
|
||||||
|
|
||||||
-- this was the end of the loop
|
-- this was the end of the loop
|
||||||
glDisable GL_CULL_FACE
|
glDisable GL_CULL_FACE
|
||||||
|
|||||||
Reference in New Issue
Block a user