Draw shape shadows using index buffer

This commit is contained in:
2021-09-21 00:43:45 +01:00
parent 5cbcbec101
commit 7f1a365cac
9 changed files with 167 additions and 41 deletions
+19 -12
View File
@@ -57,10 +57,11 @@ doDrawing pdata w = do
-- bind as much data into vbos as feasible at this point
-- poke wall points and colors
nWalls <- poke224s (shadVBOptr $ _wallTextureShader pdata) wallPointsCol
(numShapeVs,nSils) <- pokeShape
(numShapeVs,nSils,nIndices,nSilIndices) <- pokeShape
(_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata)
(shadVBOptr $ _lightingLineShadowShader pdata)
(_eboPtr $ _shapeEBO pdata)
(_eboPtr $ _silhouetteEBO pdata)
$ worldShape w
-- bind wall points, silhouette data, surface geometry
uncurry bindShaderBuffers $ unzip
@@ -68,6 +69,20 @@ doDrawing pdata w = do
, (_lightingLineShadowShader pdata, nSils)
, (_shapeShader pdata, numShapeVs)
]
bindBuffer ElementArrayBuffer $= Just (_ebo $ _shapeEBO pdata)
bufferSubData
ElementArrayBuffer
WriteToBuffer
0
(fromIntegral $ glushortSize * nIndices)
(_eboPtr $ _shapeEBO pdata)
bindBuffer ElementArrayBuffer $= Just (_ebo $ _silhouetteEBO pdata)
bufferSubData
ElementArrayBuffer
WriteToBuffer
0
(fromIntegral $ glushortSize * nIndices)
(_eboPtr $ _silhouetteEBO pdata)
-- set the coordinate uniform ready for drawing elements using world coordinates
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
@@ -90,20 +105,12 @@ doDrawing pdata w = do
pokeBindFoldableLayer shadV layerCounts $ worldPictures w
renderLayer 0 shadV layerCounts
-- drawShader (_shapeShader pdata) numShapeVs
let fs = _shapeShader pdata
currentProgram $= Just (_shadProg fs)
bindVertexArrayObject $= Just (_vao $ _shadVAO fs)
bindBuffer ElementArrayBuffer $= Just (_ebo $ _shapeEBO pdata)
bufferSubData
ElementArrayBuffer
WriteToBuffer
0
(fromIntegral $ glushortSize * numShapeVs)
(_eboPtr $ _shapeEBO pdata)
glDrawElements
(marshalEPrimitiveMode $ _shadPrim fs)
(fromIntegral numShapeVs)
(fromIntegral nIndices)
(GL_UNSIGNED_SHORT)
nullPtr
@@ -113,8 +120,8 @@ doDrawing pdata w = do
drawShader (_textureArrayShader pdata) nTextArrayVs
--draw lightmap for base buffer
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
--createLightMap pdata lightPoints nWalls nSils numShapeVs (snd $ snd $ _fboBase pdata)
createLightMap pdata lightPoints nWalls 0 0 (snd $ snd $ _fboBase pdata)
createLightMap pdata lightPoints nWalls nSils numShapeVs (snd $ snd $ _fboBase pdata)
--createLightMap pdata lightPoints nWalls 0 0 (snd $ snd $ _fboBase pdata)
colorMask $= Color4 Enabled Enabled Enabled Enabled
clearColor $= Color4 0 0 0 0
--apply lightmap to base buffer