Graphic tweaks/cleanup

This commit is contained in:
2025-12-01 12:37:54 +00:00
parent 1635ce0176
commit 25efce7a89
8 changed files with 116 additions and 146 deletions
+11 -17
View File
@@ -62,11 +62,7 @@ doDrawing' win pdata u = do
((nWins, trueNWalls), (nShapeVs, nIndices, nSilIndices)) <-
MP.liftM3
(\_ a b -> (a, b))
( pokeLayVerxs
shadV
pokeCounts
wp
)
( pokeLayVerxs shadV pokeCounts wp)
( pokeWallsWindows
(pdata ^. winVBO . vboPtr)
(pdata ^. wallVBO . vboPtr)
@@ -81,7 +77,7 @@ doDrawing' win pdata u = do
(0, 0, 0)
ws
)
nCloudVs' <-
nCloudVs' <- -- foldM (pokeCloud $ pdata ^. cloudVBO . vboPtr) 0 (w ^. cWorld . lWorld . clouds)
V.foldM'
(pokeCloud (pdata ^. cloudVBO . vboPtr))
0
@@ -162,9 +158,9 @@ doDrawing' win pdata u = do
(pdata ^. fboBase . _2 . _3)
lightPoints
pdata
-- no longer need base positions/normals
withArray [GL_COLOR_ATTACHMENT1,GL_COLOR_ATTACHMENT2] $
glInvalidateNamedFramebufferData (pdata ^. fboBase . _1 . unFBO) 2
-- -- no longer need base positions/normals
-- withArray [GL_COLOR_ATTACHMENT1,GL_COLOR_ATTACHMENT2] $
-- glInvalidateNamedFramebufferData (pdata ^. fboBase . _1 . unFBO) 2
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
--apply lightmap to base buffer
glDepthFunc GL_ALWAYS
@@ -177,8 +173,8 @@ doDrawing' win pdata u = do
--glDrawArrays GL_TRIANGLES 0 6
glDrawArrays GL_TRIANGLES 0 3
-- no longer need lighting texture
with GL_COLOR_ATTACHMENT0 $
glInvalidateNamedFramebufferData (pdata ^. fboLighting . _1 . unFBO) 1
-- with GL_COLOR_ATTACHMENT0 $
-- glInvalidateNamedFramebufferData (pdata ^. fboLighting . _1 . unFBO) 1
--draw bloom onto bloom buffer
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBloom . _1 . unFBO)
withArray [0, 0, 0, 0] $
@@ -255,6 +251,7 @@ doDrawing' win pdata u = do
when (_gr_cloud_shadows cfig) $ do
----render transparency depths
-- glDepthMask GL_TRUE
-- glDepthMask GL_TRUE
glDepthFunc GL_ALWAYS
withArray [GL_NONE, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $
glNamedFramebufferDrawBuffers (pdata ^. fboCloud . _1 . unFBO) 3
@@ -272,10 +269,7 @@ doDrawing' win pdata u = do
glDrawArrays GL_TRIANGLES 0 (fromIntegral nCloudVs * 6)
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboPos . _1 . unFBO)
withArray [0, 0, 0, 0] $
glClearNamedFramebufferfv
(pdata ^. fboPos . _1 . unFBO)
GL_COLOR
0
glClearNamedFramebufferfv (pdata ^. fboPos . _1 . unFBO) GL_COLOR 0
glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _2 . unTO)
glDepthMask GL_FALSE
glUseProgram (pdata ^. alphaDivideShader)
@@ -285,7 +279,7 @@ doDrawing' win pdata u = do
glDepthMask GL_TRUE
glDepthFunc GL_LESS
glEnable GL_BLEND
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboLighting . _1 . unFBO
createLightMap
True
(w ^. wCam)
@@ -333,7 +327,7 @@ doDrawing' win pdata u = do
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $
glNamedFramebufferDrawBuffers (pdata ^. fboCloud . _1 . unFBO) 2
glDepthFunc GL_ALWAYS
glBindTextureUnit 0 (_unTO . snd $ _fboLighting pdata)
glBindTextureUnit 0 (pdata ^. fboLighting . _2 . unTO)
glEnable GL_BLEND
glBlendFuncSeparate GL_ZERO GL_ONE_MINUS_SRC_COLOR GL_ZERO GL_ONE
glUseProgram (pdata ^. fullscreenShader)
+16 -43
View File
@@ -5,8 +5,6 @@
-}
module Framebuffer.Update (sizeFBOs) where
import Control.Lens
import Control.Monad
import Data.Preload.Render
import Dodge.Data.Config
import Dodge.WindowSize
@@ -51,14 +49,15 @@ sizeFBOs cfig rdata =
GL_NEAREST
GL_NEAREST
GL_RGBA16F
-- [fboBloom] -- fboPos probably doesn't need the alpha channel
)
>>= foldUpdateFBOTO
_gr_world_res
GL_NEAREST
GL_NEAREST
GL_RGBA8
[fboLighting]
>>= fboLighting
( resizeFBOTO'
(getWindowSize _gr_world_res cfig)
1
GL_NEAREST
GL_NEAREST
GL_RGBA8
)
>>= fboBloom
( resizeFBOTO'
(getWindowSize _gr_world_res cfig)
@@ -82,18 +81,14 @@ sizeFBOs cfig rdata =
GL_LINEAR
GL_RGBA16F
)
-- >>= foldUpdateFBOTO
-- _gr_downsize_res
-- GL_LINEAR_MIPMAP_LINEAR
-- GL_LINEAR
-- GL_RGBA16F
-- [fboHalf]
>>= foldUpdateFBOTO
(const SixteenthRes)
GL_LINEAR_MIPMAP_LINEAR
GL_LINEAR
GL_RGBA16F
[fboQuarter]
>>= fboQuarter
( resizeFBOTO'
(getWindowSize (const SixteenthRes) cfig)
1
GL_LINEAR_MIPMAP_LINEAR
GL_LINEAR
GL_RGBA16F
)
>>= fboWindow
( resizeFBOTO2
(getWindowSize _gr_world_res cfig)
@@ -102,32 +97,10 @@ sizeFBOs cfig rdata =
GL_RGBA8
GL_RGBA8
)
where
updateFBOTO' f = updateFBOTO (getWindowSize f cfig)
foldUpdateFBOTO f minfilt magfilt form =
ffoldM (updateFBOTO' f minfilt magfilt form)
ffoldM :: (Foldable t, Monad m) => (a1 -> a2 -> m a1) -> t a2 -> a1 -> m a1
ffoldM f = flip $ foldM f
resizeRBO :: GLuint -> GLsizei -> GLsizei -> IO ()
resizeRBO rboName = glNamedRenderbufferStorage rboName GL_DEPTH24_STENCIL8
updateFBOTO ::
V2 Int ->
-- | minification filter
GLenum ->
-- | magnification filter
GLenum ->
-- | internal color format
GLenum ->
RenderData ->
ALens' RenderData (FBO, TO) ->
IO RenderData
updateFBOTO wsize minfilt magfilt form pdata target = do
newfbo2 <- resizeFBOTO wsize minfilt magfilt form (pdata ^# target)
return $ storing target newfbo2 pdata
resizeFBOTO2 ::
V2 Int ->
-- | minification filter
+2
View File
@@ -34,6 +34,7 @@ pokeVerxs ::
UMV.MVector (PrimState IO) Int ->
Picture ->
IO ()
{-# INLINE pokeVerxs #-}
pokeVerxs vbos count = VFSM.mapM_ (pokeVerx vbos count) . VFSM.fromList
pokeVerx :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> Verx -> IO ()
@@ -472,6 +473,7 @@ pokeLayVerxs ::
UMV.MVector (PrimState IO) Int ->
Picture ->
IO ()
{-# INLINE pokeLayVerxs #-}
pokeLayVerxs vbos counts = VFSM.mapM_ (pokeLayVerx vbos counts) . VFSM.fromList
pokeLayVerx
+2
View File
@@ -11,9 +11,11 @@ import Foreign
import Geometry.Data
pokeCloud :: Ptr Float -> Int -> Cloud -> IO Int
{-# INLINE pokeCloud #-}
pokeCloud vptr nv = pokeCloudLike vptr nv . mkCloudCloudLike
pokeDust :: Ptr Float -> Int -> Dust -> IO Int
{-# INLINE pokeDust #-}
pokeDust vptr nv = pokeCloudLike vptr nv . mkDustCloudLike
mkCloudCloudLike :: Cloud -> (Point3, Point4)