Cleanup shadows

This commit is contained in:
2025-11-12 22:54:43 +00:00
parent cdf998a1e2
commit 5e9d337288
11 changed files with 118 additions and 428 deletions
+8 -32
View File
@@ -158,7 +158,9 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
-- 2. calculate lighting based on each fragment's position and normal
-- TODO stencil out square around light!
-- glEnable GL_SCISSOR_TEST
glDisable GL_CULL_FACE
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
withArray [x,y,z,1,r,g,b,rad] $ glNamedBufferSubData (pdata ^. lightUBO) 0 32
-- note that the stencil shadows rely on the depth buffer
-- glScissor 0 0 200 200
glDepthFunc GL_LESS
@@ -172,51 +174,25 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
glDisable GL_CULL_FACE
-- the first bit has been used to stencil out "ceilings" under which we never draw
glStencilFunc GL_NOTEQUAL 128 255
glBindVertexArray $ pdata ^. dummyVAO . vaoName
--draw wall shadows
glUseProgram shadwall
glUniform3f 0 x y z
glUniform1f 1 rad
--glBindVertexArray $ lwallShad ^. shaderVAO . vaoName -- Just (_vao $ _shadVAO lwallShad)
glBindVertexArray $ pdata ^. dummyVAO . vaoName -- Just (_vao $ _shadVAO lwallShad)
glDrawArrays GL_TRIANGLES 0 (nWalls * 18)
case shadrendertype of
GeoObjShads -> do
--draw silhouette shadows
glEnable GL_DEPTH_CLAMP
glUseProgram (_shaderUINT llinesShad)
glUniform3f 0 x y z
glUniform1f 1 rad
--glBindVertexArray (_vaoName $ _shaderVAO llinesShad)
glBindVertexArray (pdata ^. dummyVAO . vaoName)
glDrawArrays
GL_TRIANGLES
0
((fromIntegral nSils * 6) `div` 4)
--glDrawElements
-- (_unPrimitiveMode $ _shaderPrimitive llinesShad)
-- (fromIntegral nSils)
-- GL_UNSIGNED_INT
-- nullPtr
glDrawArrays GL_TRIANGLES 0 ((fromIntegral nSils * 6) `div` 4)
--draw caps on the near plane as required
glEnable GL_CULL_FACE
glCullFace GL_FRONT
glCullFace GL_BACK
glUseProgram (_shaderUINT lcapShad)
glUniform3f 0 x y z
glUniform4f 1 r g b rad
--glBindVertexArray $ lcapShad ^. shaderVAO . vaoName --Just (_vao $ _shadVAO lcapShad)
glBindVertexArray $ pdata ^. dummyVAO . vaoName
glFrontFace(GL_CW)
glDrawArrays
GL_TRIANGLES
0
--3
(fromIntegral nCaps)
glFrontFace(GL_CCW)
--glDrawElements
-- (_unPrimitiveMode $ _shaderPrimitive lcapShad)
-- (fromIntegral nCaps)
-- GL_UNSIGNED_SHORT
-- nullPtr
-- glFrontFace(GL_CW)
glDrawArrays GL_TRIANGLES 0 (fromIntegral nCaps)
-- glFrontFace(GL_CCW)
glDisable GL_DEPTH_CLAMP
_ -> return ()
--draw lightmap itself