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
+22 -9
View File
@@ -112,8 +112,18 @@ doDrawing' win pdata u = do
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata)))
glDepthMask GL_TRUE
glClearColor 0 0 0 1
glClear $ sum [GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT]
-- the following clear may not be necessary
withArray [0,0,0,1] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboBase . _1 . unFBO)
GL_COLOR
0
ptr
with 1 $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboBase . _1 . unFBO)
GL_DEPTH
0
ptr
glDepthFunc GL_LESS
-- draw wall occlusions from the camera's point of view
glUseProgram (pdata ^. lightingWallShadShader . shadName)
@@ -163,7 +173,6 @@ doDrawing' win pdata u = do
(pdata ^. fboBase . _2 . _2)
(drawCPUShadows pdata ws)
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
glClearColor 0 0 0 0
--apply lightmap to base buffer
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
glBindTexture GL_TEXTURE_2D (pdata ^. fboLighting . _2 . unTO)
@@ -177,7 +186,11 @@ doDrawing' win pdata u = do
ptr
--draw bloom onto bloom buffer
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBloom . _1 . unFBO)
glClear GL_COLOR_BUFFER_BIT
withArray [0,0,0,0] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboBloom . _1 . unFBO)
GL_COLOR
0
ptr
glDepthFunc GL_LESS
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
glDepthMask GL_FALSE
@@ -198,10 +211,13 @@ doDrawing' win pdata u = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
glDepthFunc GL_LEQUAL
glDepthMask GL_FALSE
glClearColor 0.5 0.5 0.5 0
glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
glClear GL_COLOR_BUFFER_BIT
withArray [0.5,0.5,0.5,0] $ \ptr -> glClearNamedFramebufferfv
(pdata ^. fboCloud . _1 . unFBO)
GL_COLOR
0
ptr
renderLayer MidLayer shadV layerCounts
drawShader (_windowShader pdata) nWins
-- when (_graphics_cloud_shadows cfig) $ do
@@ -225,11 +241,8 @@ doDrawing' win pdata u = do
-- (_graphics_object_shadows $ _uvConfig u)
-- (snd $ snd $ _fboCloud pdata)
-- (drawCPUShadows pdata ws)
-- glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
-- glClearColor 0 0 0 0
glInvalidateBufferData (pdata ^. vboShapes . vboName)
--apply lightmap to cloud buffer
glClearColor 0 0 0 0
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
glDepthMask GL_FALSE
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
-3
View File
@@ -211,9 +211,6 @@ preloadRender = do
-- reset to default framebuffer, ready for drawing direct to screen
glBindFramebuffer GL_FRAMEBUFFER 0
-- set the clearColor to have 1 alpha
glClearColor 0 0 0 1
shadV <- MV.new 6
zipWithM_
(MV.write shadV)
+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
-5
View File
@@ -7,7 +7,6 @@ module Shader.Poke (
memoTopPrismEdgeIndices,
) where
--import Control.Monad
import Control.Monad.Primitive
import qualified Data.Vector as V
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
@@ -231,7 +230,6 @@ pokeTopPrism cp col size ptr iptr ieptr (nv, nsi, nei) svs = do
nv' <- VFSM.foldlM' (pokeJustV cp col ptr) nv svs
nsi' <-
UV.foldM'
--(pokeTopPrismIndex nv iptr)
(pokeIndex nv iptr)
nsi
(memoTopPrismIndices V.! (size - 3))
@@ -379,7 +377,6 @@ pokeJustV ::
IO Int
{-# INLINE pokeJustV #-}
pokeJustV cp col ptr nv sh = do
--zipWithM_ f [0 ..] [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
return (nv + 1)
where
@@ -397,7 +394,6 @@ pokeJustVInvNormal ::
IO Int
{-# INLINE pokeJustVInvNormal #-}
pokeJustVInvNormal cp col ptr nv sh = do
--zipWithM_ f [0 ..] [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
return (nv + 1)
where
@@ -415,7 +411,6 @@ pokeFlatV ::
IO Int
{-# INLINE pokeFlatV #-}
pokeFlatV norm col ptr nv sh = do
--zipWithM_ f [0 ..] [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
UV.imapM_ f $ UV.fromList [x, y, z, 1, r, g, b, a, nx, ny, nz, 1]
return (nv + 1)
where