Implement (not fully working) alternate shadow volumes

This commit is contained in:
2023-02-24 19:51:41 +00:00
parent ed9a46a18d
commit bf1bd5bb0b
9 changed files with 136 additions and 116 deletions
+19 -12
View File
@@ -3,6 +3,8 @@ module Dodge.Render (
doDrawing,
) where
import qualified Data.Vector as V
import Dodge.Render.Shadow
import Control.Lens
import Control.Monad
import qualified Control.Monad.Parallel as MP
@@ -105,14 +107,14 @@ doDrawing pdata u = do
, (_windowShader pdata, nWins)
, (_textureArrayShader pdata, nFls)
]
bindBuffer ElementArrayBuffer $= Just (_ebo $ _shapeEBO pdata)
bindBuffer ElementArrayBuffer $= pdata ^? shapeEBO . ebo --Just (_ebo $ _shapeEBO pdata)
bufferSubData
ElementArrayBuffer
WriteToBuffer
0
(fromIntegral $ glushortSize * nIndices)
(_eboPtr $ _shapeEBO pdata)
bindBuffer ElementArrayBuffer $= Just (_ebo $ _silhouetteEBO pdata)
bindBuffer ElementArrayBuffer $= pdata ^? silhouetteEBO . ebo --Just (_ebo $ _silhouetteEBO pdata)
bufferSubData
ElementArrayBuffer
WriteToBuffer
@@ -127,9 +129,9 @@ doDrawing pdata u = do
clear [ColorBuffer, DepthBuffer]
depthFunc $= Just Less
-- draw wall occlusions from the camera's point of view
currentProgram $= Just (_shadProg lwShad)
uniform (head $ _shadUnis lwShad) $= viewFrom3d
bindVertexArrayObject $= Just (_vao $ _shadVAO lwShad)
currentProgram $= lwShad ^? shadProg -- Just (_shadProg lwShad)
uniform (_shadUnis lwShad V.! 0) $= viewFrom3d
bindVertexArrayObject $= lwShad ^? shadVAO . vao -- Just (_vao $ _shadVAO lwShad)
unless (debugOn Remove_LOS cfig) $
glDrawArrays
(marshalEPrimitiveMode $ _shadPrim lwShad)
@@ -144,7 +146,7 @@ doDrawing pdata u = do
--draw object shapes onto base buffer
let fs = _shapeShader pdata
currentProgram $= Just (_shadProg fs)
bindVertexArrayObject $= Just (_vao $ _shadVAO fs)
bindVertexArrayObject $= fs ^? shadVAO . vao -- Just (_vao $ _shadVAO fs)
glDrawElements
(marshalEPrimitiveMode $ _shadPrim fs)
(fromIntegral nIndices)
@@ -161,18 +163,21 @@ doDrawing pdata u = do
nWalls
nSilIndices
nIndices
(_graphics_object_shadows $ _uvConfig u)
(snd $ snd $ _fboBase pdata)
--(_graphics_object_shadows $ _uvConfig u)
(u ^. uvConfig . graphics_object_shadows)
(snd $ snd $ pdata ^. fboBase)
(drawCPUShadows pdata ws)
colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0
--apply lightmap to base buffer
bindFramebuffer Framebuffer $= fst (_fboBase pdata)
textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
bindFramebuffer Framebuffer $= pdata ^. fboBase . _1 --fst (_fboBase pdata)
--textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
textureBinding Texture2D $= pdata ^? fboLighting . _2 -- Just (snd $ _fboLighting pdata)
blend $= Enabled
blendFunc $= (Zero, OneMinusSrcColor)
drawShader (_fullscreenShader pdata) 4
--draw bloom onto bloom buffer
bindFramebuffer Framebuffer $= fst (_fboBloom pdata)
bindFramebuffer Framebuffer $= pdata ^. fboBloom . _1 --fst (_fboBloom pdata)
clear [ColorBuffer]
depthFunc $= Just Less
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
@@ -185,7 +190,7 @@ doDrawing pdata u = do
setViewportSize (round winx `div` (2 * resFact)) (round winy `div` (2 * resFact))
bindFramebuffer Framebuffer $= fst (_fboHalf1 pdata)
depthFunc $= Just Always
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
textureBinding Texture2D $= pdata ^? fboBloom . _2 -- Just (snd $ _fboBloom pdata)
blend $= Disabled
drawShader (_bloomBlurShader pdata) 4
replicateM_ 9 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
@@ -224,6 +229,7 @@ doDrawing pdata u = do
nIndices
(_graphics_object_shadows $ _uvConfig u)
(snd $ snd $ _fboCloud pdata)
(drawCPUShadows pdata ws)
colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0
--apply lightmap to cloud buffer
@@ -322,3 +328,4 @@ renderTextureWalls pdata nWalls = do
cullFace $= Just Back
drawShader (_wallTextureShader pdata) nWalls
cullFace $= Nothing