Progress towards downscaling bloom texture
This commit is contained in:
+19
-142
@@ -31,7 +31,7 @@ import Foreign
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Control.Foldl as F
|
||||
import Data.Tuple.Extra
|
||||
--import Data.Tuple.Extra
|
||||
--import Data.List
|
||||
--import Data.Bifunctor
|
||||
--import Data.Function
|
||||
@@ -73,30 +73,31 @@ doDrawing pdata w = do
|
||||
clear [ColorBuffer]
|
||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 1) pic
|
||||
bindFramebuffer Framebuffer $= (fst $ _fboColor pdata)
|
||||
clear [ColorBuffer]
|
||||
depthMask $= Disabled
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 3) pic
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 4) pic
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 5) pic
|
||||
depthMask $= Enabled
|
||||
bindFramebuffer Framebuffer $= (fst3 $ _fbo3 pdata)
|
||||
clear [ColorBuffer]
|
||||
bindFramebuffer Framebuffer $= (fst3 $ _fbo2 pdata)
|
||||
--bindFramebuffer Framebuffer $= (fst3 $ _fbo2 pdata)
|
||||
bindFramebuffer Framebuffer $= (fst $ _fboFourth1 pdata)
|
||||
viewport $= (Position 0 0, Size 600 600)
|
||||
depthFunc $= Just Always
|
||||
--blend $= Disabled
|
||||
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
|
||||
--clear [ColorBuffer]
|
||||
--blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
blendFuncSeparate $= ((Zero,One), (Zero,SrcAlpha))
|
||||
bindShaderBuffers [_fullscreenAlphaHalveShader pdata] [4]
|
||||
drawShader (_fullscreenAlphaHalveShader pdata) 4
|
||||
--blendFuncSeparate $= ((Zero,One), (Zero,SrcAlpha))
|
||||
--drawShader (_fullscreenAlphaHalveShader pdata) 4
|
||||
--blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
--drawShader (_bloomBlurShader pdata) 4
|
||||
blendFunc $= (One,Zero)
|
||||
bindShaderBuffers [_boxBlurShader pdata] [4]
|
||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
drawShader (_boxBlurShader pdata) 4
|
||||
blendFunc $= (One,Zero)
|
||||
pingPongBlur pdata
|
||||
replicateM_ 5 $ pingPongBlur pdata
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
--replicateM_ 5 $ pingPongBetween (_fboFourth1 pdata) (_fboFourth2 pdata) (_bloomBlurShader pdata)
|
||||
--replicateM_ 5 $ pingPongBlur pdata
|
||||
--blend $= Enabled
|
||||
viewport $= (Position 0 0, Size (round $ fst wins) (round $ snd wins))
|
||||
|
||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
|
||||
@@ -126,8 +127,11 @@ doDrawing pdata w = do
|
||||
blendFunc $= (Zero, OneMinusSrcAlpha)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
||||
--textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
|
||||
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||
|
||||
textureBinding Texture2D $= Just (snd $ _fboColor pdata)
|
||||
drawShader (_colorBlurShader pdata) 4
|
||||
--textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||
textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
|
||||
depthFunc $= Just Lequal
|
||||
@@ -151,133 +155,6 @@ doDrawing pdata w = do
|
||||
eTicks <- SDL.ticks
|
||||
return (eTicks - sTicks)
|
||||
|
||||
{- | Central drawing function.
|
||||
Returns a 'Word32' that should give the number of ticks it took to evaluate. -}
|
||||
doDrawing' :: RenderData -> World -> IO Word32
|
||||
doDrawing' pdata w = do
|
||||
clearColor $= Color4 0 0 0 1
|
||||
sTicks <- SDL.ticks
|
||||
clear [ColorBuffer,DepthBuffer]
|
||||
let rot = _cameraRot w
|
||||
camzoom = _cameraZoom w
|
||||
trans = _cameraCenter w
|
||||
wins = (getWindowX w,getWindowY w)
|
||||
wallPointsCol = wallsPointsAndCols w
|
||||
windowPoints = wallsWindows w
|
||||
lightPoints = lightsForGloom w
|
||||
viewFroms@(viewFromx,viewFromy) = _cameraViewFrom w
|
||||
pic = worldPictures w
|
||||
wallPoints = map fst wallPointsCol
|
||||
|
||||
-- set the coordinate uniform ready for drawing elements using world coordinates
|
||||
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
||||
|
||||
depthFunc $= Just Less
|
||||
let scPol = screenPolygon w
|
||||
-- draw the lightmap. Probably changes the bound framebufferObject
|
||||
createLightMap pdata (w ^. config . shadow_resolution) wallPoints lightPoints
|
||||
(foregroundPics w) scPol
|
||||
clear [DepthBuffer]
|
||||
|
||||
nWalls <- F.foldM (pokeShader $ _lightingOccludeShader pdata) (map Render22 wallPoints)
|
||||
bindShaderBuffers [_lightingOccludeShader pdata] [nWalls]
|
||||
currentProgram $= Just (_shaderProgram $ _lightingOccludeShader pdata)
|
||||
uniform (head $ _shaderCustomUnis $ _lightingOccludeShader pdata)
|
||||
$= Vector2 viewFromx viewFromy
|
||||
drawShader (_lightingOccludeShader pdata) nWalls
|
||||
|
||||
depthFunc $= Just Less
|
||||
-- set blending to depend upon the alpha level already present
|
||||
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
||||
_ <- renderShader (_textureArrayShader pdata) (_floorTiles w)
|
||||
|
||||
-- draw the walls
|
||||
if w ^. config . wall_textured
|
||||
then renderTextureWalls pdata wallPointsCol
|
||||
else renderBlankWalls pdata wallPointsCol
|
||||
-- I believe a more apt name would be setCeilingDepth: stops drawing of objects
|
||||
-- at points that are behind the extension of walls to the screen edge
|
||||
_ <- setWallDepth pdata wallPoints (viewFromx,viewFromy)
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 0) (polysToPic $ foregroundPics w)
|
||||
-- draw the first layer of pictures
|
||||
-- these will probably all be opaque
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 0) pic
|
||||
|
||||
-- draw opaque background to screen
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
-- we probably do not want to blend during this step
|
||||
blend $= Disabled
|
||||
depthFunc $= Just Always
|
||||
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||
-- textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
-- generateMipmap' Texture2D
|
||||
if _crHP (you w) > 0
|
||||
then do
|
||||
bindShaderBuffers [_fullscreenShader pdata] [4]
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
else do
|
||||
bindShaderBuffers [_grayscaleShader pdata] [4]
|
||||
drawShader (_grayscaleShader pdata) 4
|
||||
blend $= Enabled
|
||||
bindFramebuffer Framebuffer $= fst3 (_fbo2 pdata)
|
||||
|
||||
depthFunc $= Just Less
|
||||
clearColor $= Color4 0 0 0 0
|
||||
clear [ColorBuffer]
|
||||
|
||||
-- reset blend so that light map doesn't apply
|
||||
-- useful for drawing vivid projectiles
|
||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 1) pic
|
||||
depthMask $= Disabled
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 3) pic
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 4) pic
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 5) pic
|
||||
--depthFunc $= Just Lequal
|
||||
--_ <- renderFoldable pdata $ picToLTree (Just 0) (polysToPic $ foregroundPics w)
|
||||
--(Pictures $ concatmap (Poly3D 0 . _pyFaces) (foregroundPics w))
|
||||
|
||||
-- draw the fbo to the screen
|
||||
-- allows for post-processing
|
||||
-- first, bind the screen fbo
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
blend $= Enabled
|
||||
blendFuncSeparate $= ((SrcAlpha,OneMinusSrcAlpha),(Zero,One))
|
||||
depthFunc $= Just Always
|
||||
textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||
-- textureFilter Texture2D $= ((Linear',Just Linear') , Linear')
|
||||
-- generateMipmap' Texture2D
|
||||
if _crHP (you w) > 0
|
||||
then do
|
||||
bindShaderBuffers [_fullscreenShader pdata] [4]
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
else do
|
||||
bindShaderBuffers [_grayscaleShader pdata] [4]
|
||||
drawShader (_grayscaleShader pdata) 4
|
||||
blend $= Enabled
|
||||
--depthMask $= Enabled
|
||||
depthMask $= Disabled
|
||||
depthFunc $= Just Less
|
||||
-- reset blend so that light map applies again
|
||||
-- allows us to be certain these elements are drawn on top of those before,
|
||||
-- in case we want transparency effects
|
||||
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
|
||||
_ <- renderFoldable pdata $ picToLTree (Just 2) pic
|
||||
-- render transparent walls
|
||||
-- the ordering between these and transparent clouds perhaps presents a challenge
|
||||
renderBlankWalls pdata windowPoints
|
||||
|
||||
--depthMask $= Enabled
|
||||
|
||||
bufferUBO $ isoMatrix 0 1 (0,0) (2,2)
|
||||
depthFunc $= Just Always
|
||||
|
||||
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
|
||||
_ <- renderFoldable pdata (picToLTree Nothing $ fixedCoordPictures w)
|
||||
eTicks <- SDL.ticks
|
||||
depthMask $= Enabled
|
||||
return (eTicks - sTicks)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- note: currently assume there is only one UBO, we only bind it once at setup
|
||||
bufferUBO :: [Float] -> IO ()
|
||||
|
||||
@@ -53,17 +53,17 @@ drawFlame
|
||||
:: Point2 -- ^ Rotate direction
|
||||
-> Particle -> Picture
|
||||
drawFlame rotd pt = thePic
|
||||
where
|
||||
where
|
||||
ep = _btPos' pt
|
||||
thePic = pictures
|
||||
[ glow
|
||||
, aPic prot2 18 (scaleChange + 1,2) red
|
||||
, aPic prot 19 (scaleChange + 0.5,1.5) orange
|
||||
, aPic prot3 20 (scaleChange,1) white
|
||||
, aPic 3 prot2 18 (scaleChange + 1,2) red
|
||||
, aPic 4 prot 19 (scaleChange + 0.5,1.5) orange
|
||||
, aPic 5 prot3 20 (scaleChange,1) white
|
||||
]
|
||||
aPic :: (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
|
||||
aPic offset depth (scalex,scaley) col
|
||||
= setLayer 1
|
||||
aPic :: Int -> (Point2 -> Point2) -> Float -> Point2 -> Color -> Picture
|
||||
aPic lay offset depth (scalex,scaley) col
|
||||
= setLayer lay
|
||||
. setDepth depth
|
||||
. uncurry translate (offset ep)
|
||||
. rotate (pi * 0.5 + argV rotd)
|
||||
|
||||
Reference in New Issue
Block a user