Stencil out windows over ceilings

This commit is contained in:
2025-11-01 11:41:08 +00:00
parent d35a41944c
commit 0d0c1a72e0
3 changed files with 191 additions and 195 deletions
+7 -6
View File
@@ -132,8 +132,9 @@ doDrawing' win pdata u = do
0
-- draw wall occlusions from the camera's point of view
glDisable GL_CULL_FACE
-- glEnable GL_STENCIL_TEST
-- glStencilFunc
glEnable GL_STENCIL_TEST
glStencilFunc GL_NOTEQUAL 128 255
glStencilOp GL_KEEP GL_KEEP GL_REPLACE
unless (debugOn Remove_LOS cfig) $ do
glUseProgram (pdata ^. ceilingStencilShader . shaderUINT)
glProgramUniform3f
@@ -151,6 +152,8 @@ doDrawing' win pdata u = do
(_unPrimitiveMode $ pdata ^. ceilingStencilShader . shaderPrimitive)
0
(fromIntegral trueNWalls)
glStencilMask 127 -- to alter last seven bits
glStencilOp GL_KEEP GL_KEEP GL_KEEP
-- clear color and normals
withArray [0, 0, 0, 1] $
glClearNamedFramebufferfv (pdata ^. fboBase . _1 . unFBO) GL_COLOR 0
@@ -168,8 +171,6 @@ doDrawing' win pdata u = do
(_unPrimitiveMode $ pdata ^. wallShader . shaderPrimitive)
0
(fromIntegral trueNWalls)
--draw object pictures onto base buffer (are there any?!)
-- renderLayer BottomLayer shadV layerCounts
--draw object shapes onto base buffer
let fs = _shapeShader pdata
glUseProgram (_shaderUINT fs)
@@ -184,8 +185,6 @@ doDrawing' win pdata u = do
glBindVertexArray $ pdata ^. chasmShader . shaderVAO . vaoName
glDepthMask GL_FALSE
glDrawBuffer GL_NONE
glEnable GL_STENCIL_TEST
glStencilFunc GL_ALWAYS 0 255
glStencilOp GL_INCR GL_INCR GL_INCR
with 0 $
glClearNamedFramebufferiv
@@ -210,6 +209,8 @@ doDrawing' win pdata u = do
glDisable GL_STENCIL_TEST
glDisable GL_CULL_FACE
glEnable GL_BLEND
-- reset stencil to not draw on ceilings
glStencilFunc GL_NOTEQUAL 128 255
--draw lightmap into its own buffer
createLightMap
cfig
+1 -2
View File
@@ -158,12 +158,11 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
-- setup stencil
glColorMask GL_FALSE GL_FALSE GL_FALSE GL_FALSE
glStencilMask 127 -- so we only affect the last 7 bits
with 0 $ \ptr ->
with 0 $
glClearNamedFramebufferiv
(pdata ^. fboLighting . _1 . unFBO)
GL_STENCIL
0
ptr
glDisable GL_CULL_FACE
-- the first bit has been used to stencil out "ceilings" under which we never draw
glStencilFunc GL_NOTEQUAL 128 255