Towards working shadows

This commit is contained in:
2021-09-21 10:34:35 +01:00
parent 8854b195cc
commit 07e128bb04
2 changed files with 10 additions and 10 deletions
+4 -5
View File
@@ -56,16 +56,15 @@ doDrawing pdata w = do
-- bind as much data into vbos as feasible at this point -- bind as much data into vbos as feasible at this point
-- poke wall points and colors -- poke wall points and colors
nWalls <- poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol nWalls <- poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol
(numShapeVs,nIndices,nSilIndices) <- pokeShape (nShapeVs,nIndices,nSilIndices) <- pokeShape
(_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata) (_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata)
-- (shadVBOptr $ _lightingLineShadowShader pdata)
(_eboPtr $ _shapeEBO pdata) (_eboPtr $ _shapeEBO pdata)
(_eboPtr $ _silhouetteEBO pdata) (_eboPtr $ _silhouetteEBO pdata)
$ worldShape w $ worldShape w
-- bind wall points, silhouette data, surface geometry -- bind wall points, silhouette data, surface geometry
uncurry bindShaderBuffers $ unzip uncurry bindShaderBuffers $ unzip
[ ( _wallTextureShader pdata, nWalls) [ ( _wallTextureShader pdata, nWalls)
, (_shapeShader pdata, numShapeVs) , (_shapeShader pdata, nShapeVs)
] ]
bindBuffer ElementArrayBuffer $= Just (_ebo $ _shapeEBO pdata) bindBuffer ElementArrayBuffer $= Just (_ebo $ _shapeEBO pdata)
bufferSubData bufferSubData
@@ -116,7 +115,7 @@ doDrawing pdata w = do
drawShader (_textureArrayShader pdata) nTextArrayVs drawShader (_textureArrayShader pdata) nTextArrayVs
--draw lightmap for base buffer --draw lightmap for base buffer
bindFramebuffer Framebuffer $= fst (_fboLighting pdata) bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
createLightMap pdata lightPoints nWalls nSilIndices numShapeVs (snd $ snd $ _fboBase pdata) createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboBase pdata)
--createLightMap pdata lightPoints nWalls 0 0 (snd $ snd $ _fboBase pdata) --createLightMap pdata lightPoints nWalls 0 0 (snd $ snd $ _fboBase pdata)
colorMask $= Color4 Enabled Enabled Enabled Enabled colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0 clearColor $= Color4 0 0 0 0
@@ -171,7 +170,7 @@ doDrawing pdata w = do
depthMask $= Disabled depthMask $= Disabled
blend $= Enabled blend $= Enabled
bindFramebuffer Framebuffer $= fst (_fboLighting pdata) bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
createLightMap pdata lightPoints nWalls nSilIndices numShapeVs (snd $ snd $ _fboCloud pdata) createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboCloud pdata)
colorMask $= Color4 Enabled Enabled Enabled Enabled colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0 clearColor $= Color4 0 0 0 0
--apply lightmap to cloud buffer --apply lightmap to cloud buffer
+6 -5
View File
@@ -22,7 +22,6 @@ import qualified Data.Vector.Mutable as MV
import qualified Data.Vector.Fusion.Stream.Monadic as VS import qualified Data.Vector.Fusion.Stream.Monadic as VS
import Control.Monad.Primitive import Control.Monad.Primitive
import Control.Monad import Control.Monad
import Data.Bifoldable
--import qualified Data.DList as DL --import qualified Data.DList as DL
pokeVerxs pokeVerxs
@@ -91,11 +90,13 @@ pokeTopPrismIndex nv iptr ni ioff = do
topPrismEdgeIndices :: Int -> [Int] topPrismEdgeIndices :: Int -> [Int]
topPrismEdgeIndices n = concatMap f [0..n-1] topPrismEdgeIndices n = concatMap f [0..n-1]
where where
f i = f i = map g
[ i, (i+2) `mod` n, i+1, (i+4) `mod` n [ 0 , 2 , 1 , 4
, i, i+1, (i+4) `mod` n, (i+3) `mod` n , 0 , 1 ,-2 , 3
, i+1, (i+5) `mod` n, i, (i+3) `mod` n , 1 , 3 ,-1 , 2
] ]
where
g j = (2 * i + j) `mod` n
topPrismIndices :: Int -> [Int] topPrismIndices :: Int -> [Int]
topPrismIndices n = concatMap f [1..n-2] -- triangles on top face topPrismIndices n = concatMap f [1..n-2] -- triangles on top face