DSA glClear

This commit is contained in:
2023-03-16 22:43:48 +00:00
parent 9e89dcebe7
commit 100fdc102d
4 changed files with 67 additions and 31 deletions
+45 -14
View File
@@ -57,8 +57,11 @@ createLightMap cfig pdata lightPoints nWalls nSils nCaps shadsdrawtype toPos dra
glDepthMask GL_FALSE
-- clearColor is specified differently in preloadRender
-- the colors are inverted
glClearColor 1 1 1 1
glClear GL_COLOR_BUFFER_BIT
withArray [1,1,1,1] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
-- for each of the lights:
-- 1. stencil out the shadows from this light's point of view
-- 2. calculate lighting based on each fragment's position
@@ -71,7 +74,11 @@ createLightMap cfig pdata lightPoints nWalls nSils nCaps shadsdrawtype toPos dra
glDepthFunc GL_LESS
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
glClear GL_STENCIL_BUFFER_BIT
with 0 $ \ptr -> glClearNamedFramebufferiv
(pdata ^. fboLighting . _1 . unFBO)
GL_STENCIL
0
ptr
glDisable GL_CULL_FACE
glStencilFunc GL_ALWAYS 0 255
--draw lightmap itself
@@ -94,11 +101,17 @@ createLightMap cfig pdata lightPoints nWalls nSils nCaps shadsdrawtype toPos dra
glDisable GL_STENCIL_TEST
NoLighting -> do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
glClearColor 0 0 0 1
-- glClearDepth 0
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
glClear $ GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT
-- glClearDepth 1
withArray [0,0,0,1] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
with 1 $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_DEPTH
0
ptr
glDisable GL_CULL_FACE
--bindTO toPos
glBindTextureUnit 0 (toPos ^. unTO)
@@ -115,8 +128,11 @@ createLightMap cfig pdata lightPoints nWalls nSils nCaps shadsdrawtype toPos dra
glDepthMask GL_FALSE
-- clearColor is specified differently in preloadRender
-- the colors are inverted
glClearColor 1 1 1 1
glClear GL_COLOR_BUFFER_BIT
withArray [1,1,1,1] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
-- for each of the lights:
-- 1. stencil out the shadows from this light's point of view
-- 2. calculate lighting based on each fragment's position
@@ -129,7 +145,11 @@ createLightMap cfig pdata lightPoints nWalls nSils nCaps shadsdrawtype toPos dra
glDepthFunc GL_LESS
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
glClear GL_STENCIL_BUFFER_BIT
with 0 $ \ptr -> glClearNamedFramebufferiv
(pdata ^. fboLighting . _1 . unFBO)
GL_STENCIL
0
ptr
glDisable GL_CULL_FACE
glStencilFunc GL_ALWAYS 0 255
--draw wall shadows
@@ -235,8 +255,16 @@ instanceLightMap cfig pdata lightPoints nWalls nSils nCaps toPos = do
1
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboShadow . _1 . unFBO
glDepthMask GL_FALSE
glClearColor 0 0 0 0
glClear $ GL_COLOR_BUFFER_BIT + GL_STENCIL_BUFFER_BIT
withArray [0,0,0,0] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboShadow . _1 . unFBO)
GL_COLOR
0
ptr
with 0 $ \ptr -> glClearNamedFramebufferiv
(pdata ^. fboShadow . _1 . unFBO)
GL_STENCIL
0
ptr
-- stencil out the shadows from each light's point of view
-- setup stencil
glEnable GL_STENCIL_TEST
@@ -289,8 +317,11 @@ instanceLightMap cfig pdata lightPoints nWalls nSils nCaps toPos = do
glDisable GL_STENCIL_TEST
--draw to the lighting framebuffer here
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
glClearColor 1 1 1 1
glClear GL_COLOR_BUFFER_BIT
withArray [1,1,1,1] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
glBindTexture GL_TEXTURE_2D_ARRAY (pdata ^. fboShadow . _2 . _1 . unTO)
glEnable GL_BLEND
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR