Cleanup shadows
This commit is contained in:
@@ -42,6 +42,7 @@ data RenderData = RenderData
|
||||
, _fboLighting :: (FBO, TO)
|
||||
, _rboBaseBloom :: GLuint -- RenderbufferObject id
|
||||
, _matUBO :: GLuint -- BufferObject id
|
||||
, _lightUBO :: GLuint -- BufferObject id
|
||||
-- , _winSSBO :: GLuint
|
||||
-- , _wallSSBO :: GLuint
|
||||
-- , _shapeSSBO :: GLuint
|
||||
|
||||
@@ -40,6 +40,10 @@ preloadRender = do
|
||||
glNamedBufferStorage theUBO 64 nullPtr GL_DYNAMIC_STORAGE_BIT
|
||||
glBindBufferBase GL_UNIFORM_BUFFER 0 theUBO
|
||||
|
||||
lightubo <- mglCreate glCreateBuffers
|
||||
glNamedBufferStorage lightubo 32 nullPtr GL_DYNAMIC_STORAGE_BIT
|
||||
glBindBufferBase GL_UNIFORM_BUFFER 1 lightubo
|
||||
|
||||
winssbo <- mglCreate glCreateBuffers
|
||||
let winssbosize = sizeOf (0 :: Float) * 8 * 1024
|
||||
glNamedBufferStorage winssbo (fromIntegral winssbosize) nullPtr GL_DYNAMIC_STORAGE_BIT
|
||||
@@ -222,6 +226,7 @@ preloadRender = do
|
||||
, _fboPos = fboPosName
|
||||
, _rboBaseBloom = rboBaseBloomName
|
||||
, _matUBO = theUBO
|
||||
, _lightUBO = lightubo
|
||||
, _vboShapes = shVBO
|
||||
, _floorVBO = floorvbo
|
||||
, _floorShader = floorshader
|
||||
|
||||
+8
-32
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user