Work on cloud/window transparency
This commit is contained in:
+55
-26
@@ -76,7 +76,7 @@ doDrawing' win pdata u = do
|
||||
wallsToPoke
|
||||
)
|
||||
( pokeShape
|
||||
(drawShadowsByImportance $ cfig ^. graphics_shadow_size)
|
||||
(drawShadowsByImportance $ cfig ^. gr_shadow_size)
|
||||
(_vboPtr $ _vboShapes pdata)
|
||||
(_eboPtr $ _shapeEBO pdata)
|
||||
(_eboPtr $ _silhouetteEBO pdata)
|
||||
@@ -111,7 +111,7 @@ doDrawing' win pdata u = do
|
||||
]
|
||||
-- set the coordinate uniform ready for drawing elements using world coordinates
|
||||
bufferPerspectiveMatrixUBO cfig (w ^. wCam) (pdata ^. matUBO)
|
||||
setViewport _graphics_world_resolution cfig
|
||||
setViewport _gr_world_res cfig
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
glDepthMask GL_TRUE
|
||||
glDisable GL_BLEND
|
||||
@@ -257,7 +257,7 @@ doDrawing' win pdata u = do
|
||||
|
||||
--setup downscale viewport for blurring bloom
|
||||
--setViewportSize (round winx `div` (2 * resFact)) (round winy `div` (2 * resFact))
|
||||
setViewport _graphics_downsize_resolution cfig
|
||||
setViewport _gr_downsize_res cfig
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboHalf1 pdata)))
|
||||
glDepthFunc GL_ALWAYS
|
||||
glBindTextureUnit 0 (pdata ^. fboBloom . _2 . unTO)
|
||||
@@ -271,11 +271,11 @@ doDrawing' win pdata u = do
|
||||
-- glClearNamedFramebufferfv (pdata ^. fboHalf2 . _1 . unFBO) GL_COLOR 0
|
||||
-- glBlendFunc GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
drawShader (_bloomBlurShader pdata) 4
|
||||
when (cfig ^. graphics_bloom) $ do
|
||||
when (cfig ^. gr_bloom) $ do
|
||||
replicateM_ 2 $ pingPongBetween
|
||||
(_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||
glEnable GL_BLEND
|
||||
setViewport _graphics_world_resolution cfig
|
||||
setViewport _gr_world_res cfig
|
||||
--draw clouds onto cloud buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboCloud . _1 . unFBO)
|
||||
glDepthFunc GL_LEQUAL
|
||||
@@ -297,15 +297,15 @@ doDrawing' win pdata u = do
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
glEnable GL_CULL_FACE
|
||||
glEnable GL_DEPTH_CLAMP
|
||||
glCullFace GL_BACK
|
||||
drawShader (_windowShader pdata) nWins
|
||||
glDisable GL_DEPTH_CLAMP
|
||||
glDisable GL_CULL_FACE
|
||||
when (_graphics_cloud_shadows cfig) $ do
|
||||
-- glEnable GL_CULL_FACE
|
||||
-- glEnable GL_DEPTH_CLAMP
|
||||
-- glCullFace GL_BACK
|
||||
---- drawShader (_windowShader pdata) nWins
|
||||
-- glDisable GL_DEPTH_CLAMP
|
||||
-- glDisable GL_CULL_FACE
|
||||
when (_gr_cloud_shadows cfig) $ do
|
||||
----render transparency depths
|
||||
glDepthMask GL_TRUE
|
||||
-- glDepthMask GL_TRUE
|
||||
glDepthFunc GL_ALWAYS
|
||||
glDisable GL_BLEND
|
||||
withArray [GL_NONE, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2] $
|
||||
@@ -317,24 +317,25 @@ doDrawing' win pdata u = do
|
||||
glEnable GL_BLEND
|
||||
-- we sum the positions weighted by alpha, and sum the alpha
|
||||
glBlendFuncSeparatei 1 GL_SRC_ALPHA GL_ONE GL_ONE GL_ONE
|
||||
--glBlendFuncSeparatei 1 GL_ONE GL_ZERO GL_ONE GL_ZERO
|
||||
-- and sum the normals weighted by alpha
|
||||
--glBlendFunci 2 GL_SRC_ALPHA GL_ONE
|
||||
glBlendFunci 2 GL_SRC_ALPHA GL_ONE
|
||||
glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
glDepthMask GL_TRUE
|
||||
-- glDepthMask GL_TRUE
|
||||
glDrawElements
|
||||
(pdata ^. cloudShader . shaderPrimitive . unPrimitiveMode)
|
||||
(fromIntegral nCloudIs)
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
---
|
||||
glEnable GL_CULL_FACE
|
||||
glEnable GL_DEPTH_CLAMP
|
||||
glCullFace GL_BACK
|
||||
drawShader (_windowShader pdata) nWins
|
||||
glDisable GL_DEPTH_CLAMP
|
||||
glDisable GL_CULL_FACE
|
||||
-- glEnable GL_CULL_FACE
|
||||
-- glEnable GL_DEPTH_CLAMP
|
||||
-- glCullFace GL_BACK
|
||||
---- drawShader (_windowShader pdata) nWins
|
||||
-- glDisable GL_DEPTH_CLAMP
|
||||
-- glDisable GL_CULL_FACE
|
||||
-- drawShader (_windowShader pdata) nWins
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboPos . _1 . unFBO)
|
||||
withArray [0, 0, 0, 0] $ \ptr ->
|
||||
@@ -360,6 +361,22 @@ doDrawing' win pdata u = do
|
||||
(pdata ^. fboCloud . _2 . _3)
|
||||
lightPoints
|
||||
pdata
|
||||
--draw windows onto window buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboWindow . _1 . unFBO)
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1] $
|
||||
glNamedFramebufferDrawBuffers (pdata ^. fboWindow . _1 . unFBO) 2
|
||||
withArray [0, 0, 0, 0] $
|
||||
glClearNamedFramebufferfv (pdata ^. fboWindow . _1 . unFBO) GL_COLOR 0
|
||||
withArray [0, 0, 0, 0] $
|
||||
glClearNamedFramebufferfv (pdata ^. fboWindow . _1 . unFBO) GL_COLOR 1
|
||||
glEnable GL_CULL_FACE
|
||||
glEnable GL_DEPTH_CLAMP
|
||||
glDepthFunc GL_LEQUAL
|
||||
glCullFace GL_BACK
|
||||
glDisable GL_BLEND
|
||||
drawShader (_windowShader pdata) nWins
|
||||
glDisable GL_DEPTH_CLAMP
|
||||
glDisable GL_CULL_FACE
|
||||
glInvalidateBufferData (pdata ^. vboShapes . vboName)
|
||||
--apply lightmap to cloud buffer
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
@@ -374,13 +391,24 @@ doDrawing' win pdata u = do
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
|
||||
-- bind base buffer for drawing clouds and bloom
|
||||
--glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata)))
|
||||
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO)
|
||||
|
||||
--draw shadowed clouds onto base buffer
|
||||
glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
-- --draw shadowed clouds onto base buffer
|
||||
-- glBindTextureUnit 0 (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
-- drawShader (_fullscreenShader pdata) 4
|
||||
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- --draw windows onto base buffer
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
glBindTextureUnit 0 (pdata ^. fboWindow . _2 . _1 . unTO)
|
||||
glBindTextureUnit 1 (pdata ^. fboWindow . _2 . _2 . unTO)
|
||||
glBindTextureUnit 2 (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
--glBindTextureUnit 3 (pdata ^. fboCloud . _2 . _2 . unTO)
|
||||
glBindTextureUnit 3 (pdata ^. fboPos . _2 . unTO)
|
||||
drawShader (_transparencyCompShader pdata) 4
|
||||
|
||||
--Draw blurred bloom onto base buffer
|
||||
glEnable GL_BLEND
|
||||
@@ -388,7 +416,8 @@ doDrawing' win pdata u = do
|
||||
--glBlendFunc GL_ONE GL_ONE
|
||||
glBindTextureUnit 0 (_unTO . snd $ _fboHalf1 pdata)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
|
||||
|
||||
--set viewport for radial distortion
|
||||
--setViewportSize (round winx) (round winy)
|
||||
@@ -397,7 +426,7 @@ doDrawing' win pdata u = do
|
||||
glBlendFunc GL_ONE GL_ZERO
|
||||
-- perform any radial distortion
|
||||
-- this is hideous
|
||||
case (getDistortions cfig w, cfig ^. graphics_distortions) of
|
||||
case (getDistortions cfig w, cfig ^. gr_distortions) of
|
||||
(rds, x) | null rds || not x -> do
|
||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
@@ -440,7 +469,7 @@ bufferPerspectiveMatrixUBO cfig cam uboid = withArray
|
||||
|
||||
getDistortions :: Config -> World -> [Distortion]
|
||||
getDistortions cfig w
|
||||
| cfig ^. graphics_distortions = w ^. cWorld . lWorld . distortions
|
||||
| cfig ^. gr_distortions = w ^. cWorld . lWorld . distortions
|
||||
| otherwise = []
|
||||
|
||||
setViewport :: (Config -> ResFactor) -> Config -> IO ()
|
||||
|
||||
Reference in New Issue
Block a user