From cd224437e7cc5ac855ad79bae33ceedcfd5e704b Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 24 Mar 2023 01:46:25 +0000 Subject: [PATCH] Cleanup rendering --- src/Dodge/Data/Config.hs | 4 ++++ src/Dodge/Menu.hs | 6 ++++-- src/Dodge/Render.hs | 22 +++++++--------------- src/Render.hs | 1 - 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Dodge/Data/Config.hs b/src/Dodge/Data/Config.hs index 69ff3e7e3..b8662b514 100644 --- a/src/Dodge/Data/Config.hs +++ b/src/Dodge/Data/Config.hs @@ -39,6 +39,8 @@ data Configuration = Configuration , _volume_sound :: Float , _volume_music :: Float , _graphics_cloud_shadows :: Bool + , _graphics_distortions :: Bool + , _graphics_bloom :: Bool , _graphics_object_shadows :: ShadowRendering , _graphics_resolution_factor :: ResFactor , _graphics_num_shadow_casters :: NumShadowCasters @@ -108,7 +110,9 @@ defaultConfig = , _volume_sound = 1 , _volume_music = 0 , _graphics_cloud_shadows = True + , _graphics_bloom = True , _graphics_object_shadows = GeoObjShads + , _graphics_distortions = True , _graphics_resolution_factor = QuarterRes , _graphics_num_shadow_casters = toEnum 10 , _windowX = 800 diff --git a/src/Dodge/Menu.hs b/src/Dodge/Menu.hs index 316ba99d7..25d950fd6 100644 --- a/src/Dodge/Menu.hs +++ b/src/Dodge/Menu.hs @@ -183,9 +183,11 @@ graphicsMenu = titleOptionsMenu "OPTIONS:GRAPHICS" graphicsMenuOptions graphicsMenuOptions :: [MenuOption] graphicsMenuOptions = [ makeEnumOption graphics_resolution_factor "RESOLUTION" (uvIOEffects .~ updateFramebufferSize) - , makeEnumOption graphics_object_shadows "OBJECT SHADOWS" id + , makeEnumOption graphics_object_shadows "SHADOW DETAIL" id + , makeEnumOption graphics_distortions "ENABLE DISTORTIONS" id + , makeEnumOption graphics_bloom "ENABLE BLOOM" id , makeBoolOption graphics_cloud_shadows "CLOUD SHADOWS" - , makeEnumOption graphics_num_shadow_casters "SHADOW CASTERS" id + , makeEnumOption graphics_num_shadow_casters "NUM SHADOW CASTERS" id ] gameOverMenu :: Universe -> ScreenLayer diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 9652dbb7f..2a3b6d0cd 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -337,7 +337,7 @@ doDrawing' win pdata u = do glBlendFunc GL_ONE GL_ZERO -- perform any radial distortion -- this is hideous - case w ^. cWorld . lWorld . distortions of + case getDistortions cfig w of [] -> do glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO glBindFramebuffer GL_FRAMEBUFFER 0 @@ -355,27 +355,19 @@ doDrawing' win pdata u = do bindings = zipWith (>>) (map bindFBO fboList) (map (glBindTextureUnit 1 . _unTO) toList) zipWithM_ (>>) bindings $ map bindDrawDist rds glDepthFunc GL_ALWAYS + glDepthMask GL_FALSE glEnable GL_BLEND glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA renderLayer DebugLayer shadV layerCounts -- draw overlay - glDepthFunc GL_ALWAYS - glDepthMask GL_FALSE - glEnable GL_BLEND - glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. orthonormalMatUBO) renderLayer FixedCoordLayer shadV layerCounts - glDepthMask GL_TRUE SDL.glSwapWindow win --------------------------------------------------------------------------------- --- note: currently assume there is only one UBO, we only bind it once at setup ---bufferUBO :: GLuint -> [Float] -> IO () ---bufferUBO ubo mat = withArray mat $ \ptr -> --- glNamedBufferSubData ubo 0 64 ptr +getDistortions :: Configuration -> World -> [Distortion] +getDistortions cfig w + | cfig ^. graphics_distortions = w ^. cWorld . lWorld . distortions + | otherwise = [] setViewportSize :: Int -> Int -> IO () -setViewportSize x y = - glViewport 0 0 (fromIntegral x) (fromIntegral y) - ---cullFace $= Nothing +setViewportSize x y = glViewport 0 0 (fromIntegral x) (fromIntegral y) diff --git a/src/Render.hs b/src/Render.hs index 418434ed6..9779054c2 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -186,7 +186,6 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li nullPtr --draw caps on the near plane as required glEnable GL_CULL_FACE - glCullFace GL_BACK glCullFace GL_FRONT glUseProgram (_shaderUINT lcapShad) glUniform3f 0 x y z