Add graphics option to hide object shadows

This commit is contained in:
2022-04-25 23:53:33 +01:00
parent fa8d8b5899
commit cbef0a37f6
4 changed files with 35 additions and 26 deletions
+2
View File
@@ -11,6 +11,7 @@ data Configuration = Configuration
, _volume_music :: Float , _volume_music :: Float
, _graphics_wall_textured :: Bool , _graphics_wall_textured :: Bool
, _graphics_cloud_shadows :: Bool , _graphics_cloud_shadows :: Bool
, _graphics_object_shadows :: Bool
, _graphics_resolution_factor :: ResFactor , _graphics_resolution_factor :: ResFactor
, _windowX :: Float , _windowX :: Float
, _windowY :: Float , _windowY :: Float
@@ -58,6 +59,7 @@ defaultConfig = Configuration
, _volume_music = 1 , _volume_music = 1
, _graphics_wall_textured = True , _graphics_wall_textured = True
, _graphics_cloud_shadows = True , _graphics_cloud_shadows = True
, _graphics_object_shadows = True
, _graphics_resolution_factor = FullRes , _graphics_resolution_factor = FullRes
, _windowX = 800 , _windowX = 800
, _windowY = 600 , _windowY = 600
+2 -1
View File
@@ -134,7 +134,8 @@ graphicsMenuOptions :: [MenuOption]
graphicsMenuOptions = graphicsMenuOptions =
[ makeEnumOption ScancodeS graphics_resolution_factor "RESOLUTION" updateFramebufferSize [ makeEnumOption ScancodeS graphics_resolution_factor "RESOLUTION" updateFramebufferSize
, makeBoolOption ScancodeW graphics_wall_textured "WALL TEXTURES" , makeBoolOption ScancodeW graphics_wall_textured "WALL TEXTURES"
, makeBoolOption ScancodeD graphics_cloud_shadows "CLOUD SHADOWS" , makeBoolOption ScancodeO graphics_object_shadows "OBJECT SHADOWS"
, makeBoolOption ScancodeC graphics_cloud_shadows "CLOUD SHADOWS"
] ]
gameOverMenu :: ScreenLayer gameOverMenu :: ScreenLayer
+6 -2
View File
@@ -131,7 +131,9 @@ doDrawing pdata u = do
drawShader (_textureArrayShader pdata) nFls drawShader (_textureArrayShader pdata) nFls
--draw lightmap into its own buffer --draw lightmap into its own buffer
bindFramebuffer Framebuffer $= fst (_fboLighting pdata) bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboBase pdata) createLightMap pdata lightPoints nWalls nSilIndices nIndices
(_graphics_object_shadows $ _config u)
(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
--apply lightmap to base buffer --apply lightmap to base buffer
@@ -185,7 +187,9 @@ doDrawing pdata u = do
depthMask $= Disabled depthMask $= Disabled
blend $= Enabled blend $= Enabled
bindFramebuffer Framebuffer $= fst (_fboLighting pdata) bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
createLightMap pdata lightPoints nWalls nSilIndices nIndices (snd $ snd $ _fboCloud pdata) createLightMap pdata lightPoints nWalls nSilIndices nIndices
(_graphics_object_shadows $ _config u)
(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
+25 -23
View File
@@ -32,9 +32,10 @@ createLightMap
-> Int -- ^ number of walls -> Int -- ^ number of walls
-> Int -- ^ number of silhoutte lines to draw -> Int -- ^ number of silhoutte lines to draw
-> Int -- ^ number of "caps" to attempt to draw -> Int -- ^ number of "caps" to attempt to draw
-> Bool -- ^ whether to draw object shadows or not
-> TextureObject -- ^ the texture object giving positions -> TextureObject -- ^ the texture object giving positions
-> IO () -> IO ()
createLightMap pdata lightPoints nWalls nSils nCaps toPos = do createLightMap pdata lightPoints nWalls nSils nCaps drawObjShads toPos = do
let llsShad = _lightingLineShadowShader pdata let llsShad = _lightingLineShadowShader pdata
let lcShad = _lightingCapShader pdata let lcShad = _lightingCapShader pdata
let lwShad = _lightingWallShadShader pdata let lwShad = _lightingWallShadShader pdata
@@ -69,28 +70,29 @@ createLightMap pdata lightPoints nWalls nSils nCaps toPos = do
(marshalEPrimitiveMode $ _shadPrim lwShad) (marshalEPrimitiveMode $ _shadPrim lwShad)
0 0
(fromIntegral nWalls) (fromIntegral nWalls)
--drawShader lwShad nWalls if drawObjShads then do
--draw silhouette shadows --draw silhouette shadows
currentProgram $= Just (_shadProg llsShad) currentProgram $= Just (_shadProg llsShad)
uniform (head $ _shadUnis $ _lightingLineShadowShader pdata) uniform (head $ _shadUnis $ _lightingLineShadowShader pdata)
$= Vector3 x y z $= Vector3 x y z
bindVertexArrayObject $= Just (_vao $ _shadVAO llsShad) bindVertexArrayObject $= Just (_vao $ _shadVAO llsShad)
glDrawElements glDrawElements
(marshalEPrimitiveMode $ _shadPrim llsShad) (marshalEPrimitiveMode $ _shadPrim llsShad)
(fromIntegral nSils) (fromIntegral nSils)
GL_UNSIGNED_SHORT GL_UNSIGNED_SHORT
nullPtr nullPtr
cullFace $= Just Back cullFace $= Just Back
--draw caps on the near plane as required --draw caps on the near plane as required
currentProgram $= Just (_shadProg lcShad) currentProgram $= Just (_shadProg lcShad)
uniform (head $ _shadUnis lcShad) uniform (head $ _shadUnis lcShad)
$= Vector3 x y z $= Vector3 x y z
bindVertexArrayObject $= Just (_vao $ _shadVAO lcShad) bindVertexArrayObject $= Just (_vao $ _shadVAO lcShad)
glDrawElements glDrawElements
(marshalEPrimitiveMode $ _shadPrim lcShad) (marshalEPrimitiveMode $ _shadPrim lcShad)
(fromIntegral nCaps) (fromIntegral nCaps)
GL_UNSIGNED_SHORT GL_UNSIGNED_SHORT
nullPtr nullPtr
else return ()
--draw lightmap itself --draw lightmap itself
depthFunc $= Just Always depthFunc $= Just Always
-- bind world position texture -- bind world position texture