Use immutable storage for fullscreen vbo
This commit is contained in:
+25
-10
@@ -5,6 +5,7 @@ module Dodge.Render (
|
||||
|
||||
--import qualified Data.Vector as V
|
||||
|
||||
import Data.List (sortOn)
|
||||
import Shader.Poke.Cloud
|
||||
import GLHelp
|
||||
import Control.Lens
|
||||
@@ -96,7 +97,7 @@ doDrawing' win pdata u = do
|
||||
]
|
||||
bufferPokedVBO (_vboShapes pdata) nShapeVs
|
||||
(nCloudVs,nCloudIs) <- foldM (pokeCloud (pdata ^. cloudVBO . vboPtr) (pdata ^. cloudEBO . eboPtr))
|
||||
(0,0) (w ^. cWorld . lWorld . clouds)
|
||||
(0,0) (sortOn (^. clPos . _3) $ w ^. cWorld . lWorld . clouds)
|
||||
bufferPokedVBO (pdata ^. cloudVBO) nCloudVs
|
||||
glNamedBufferSubData
|
||||
(_eboName $ _cloudEBO pdata)
|
||||
@@ -208,7 +209,8 @@ doDrawing' win pdata u = do
|
||||
glBindTexture GL_TEXTURE_2D (pdata ^. fboLighting . _2 . unTO)
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
|
||||
drawShader (fst $ _fullscreenShader pdata) 4
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
--drawShader (fst $ _fullscreenShader pdata) 4
|
||||
with GL_COLOR_ATTACHMENT0 $ \ptr ->
|
||||
glInvalidateNamedFramebufferData
|
||||
(pdata ^. fboLighting . _1 . unFBO)
|
||||
@@ -241,7 +243,14 @@ doDrawing' win pdata u = do
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
glDepthFunc GL_LEQUAL
|
||||
glDepthMask GL_FALSE
|
||||
glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
--blendFunc $= (SrcAlphaSaturate,One)
|
||||
--blendColor $= Color4 0.5 0.5 0.5 0.5
|
||||
--blendFuncSeparate $= ((SrcAlphaSaturate,One) , (One,OneMinusSrcAlpha))
|
||||
--blendFuncSeparate $= ((SrcAlpha, OneMinusSrcAlpha), (One, OneMinusSrcAlpha))
|
||||
--glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE_MINUS_DST_ALPHA GL_ONE
|
||||
--glBlendFuncSeparate GL_SRC_ALPHA_SATURATE GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
--glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
withArray [0.5,0.5,0.5,0] $ \ptr -> glClearNamedFramebufferfv
|
||||
(pdata ^. fboCloud . _1 . unFBO)
|
||||
@@ -274,10 +283,15 @@ doDrawing' win pdata u = do
|
||||
2
|
||||
ptr
|
||||
glEnable GL_BLEND
|
||||
--glDisable GL_BLEND
|
||||
-- the idea is to (roughly) get the average position
|
||||
glBlendFunci 1 GL_ONE_MINUS_DST_ALPHA GL_DST_ALPHA
|
||||
-- and to sum the normals
|
||||
glBlendFunci 2 GL_ONE GL_ONE
|
||||
--glBlendFunci 1 GL_ONE_MINUS_DST_ALPHA GL_DST_ALPHA
|
||||
-- or, if we order the clouds, just get the top pos
|
||||
glBlendFunci 1 GL_ONE GL_ZERO
|
||||
-- and to sum the normals (based on the alpha)
|
||||
glBlendFunci 2 GL_SRC_ALPHA GL_ONE
|
||||
-- just get the top normal
|
||||
-- glBlendFunci 2 GL_ONE GL_ZERO
|
||||
glUseProgram (pdata ^. cloudShader . shaderUINT)
|
||||
glBindVertexArray $ pdata ^. cloudShader . shaderVAO . vaoName
|
||||
glDrawElements
|
||||
@@ -286,6 +300,7 @@ doDrawing' win pdata u = do
|
||||
GL_UNSIGNED_SHORT
|
||||
nullPtr
|
||||
drawShader (_windowShader pdata) nWins
|
||||
glEnable GL_BLEND
|
||||
----draw lightmap for cloud buffer
|
||||
glDepthMask GL_FALSE
|
||||
glDepthFunc GL_LEQUAL
|
||||
@@ -310,7 +325,7 @@ doDrawing' win pdata u = do
|
||||
glBindTexture GL_TEXTURE_2D (_unTO . snd $ _fboLighting pdata)
|
||||
glEnable GL_BLEND
|
||||
glBlendFuncSeparate GL_ZERO GL_ONE_MINUS_SRC_COLOR GL_ZERO GL_ONE
|
||||
drawShader (fst $ _fullscreenShader pdata) 4
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
-- bind base buffer for drawing bloom then clouds
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata)))
|
||||
@@ -318,11 +333,11 @@ doDrawing' win pdata u = do
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE
|
||||
glBindTexture GL_TEXTURE_2D (_unTO . snd $ _fboHalf1 pdata)
|
||||
drawShader (fst $ _fullscreenShader pdata) 4
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
--draw shadowed clouds onto base buffer
|
||||
glBindTexture GL_TEXTURE_2D (pdata ^. fboCloud . _2 . _1 . unTO)
|
||||
drawShader (fst $ _fullscreenShader pdata) 4
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
--set viewport for radial distortion
|
||||
setViewportSize (round winx) (round winy)
|
||||
glDepthFunc GL_ALWAYS
|
||||
@@ -332,7 +347,7 @@ doDrawing' win pdata u = do
|
||||
[] -> do
|
||||
bindTO $ pdata ^. fboBase . _2 . _1
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
drawShader (fst $ _fullscreenShader pdata) 4
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
rds -> do
|
||||
let bindDrawDist :: Distortion -> IO ()
|
||||
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
||||
|
||||
Reference in New Issue
Block a user