Downsample when blurring bloom
This commit is contained in:
@@ -3,10 +3,12 @@ in vec2 vTexPos;
|
||||
out vec4 fColor;
|
||||
const vec2 winSize = vec2 (300,300);
|
||||
// note that the above opening bracket should be the first in this file
|
||||
// this is so that the window size can be extracted and the shader recompiled on
|
||||
// the fly
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
const float hOff = 4.0 / winSize.x;
|
||||
const float vOff = 4.0 / winSize.y;
|
||||
const float hOff = 3.0 / winSize.x;
|
||||
const float vOff = 3.0 / winSize.y;
|
||||
const float frac = 1.0 / 9;
|
||||
const vec2 off[9] = vec2[]
|
||||
( vec2( vOff,hOff )
|
||||
|
||||
+7
-5
@@ -104,21 +104,21 @@ doDrawing pdata w = do
|
||||
renderLayer 5 shadV layerCounts
|
||||
|
||||
depthMask $= Enabled
|
||||
-- this is not ideal if the original is not divisible by 2
|
||||
viewport $= (Position 0 0
|
||||
, divideSize (2 * (w ^. config . shadow_resolution)) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||
bindFramebuffer Framebuffer $= fst (_fboFourth1 pdata)
|
||||
--viewport $= (Position 0 0, Size 300 300)
|
||||
depthFunc $= Just Always
|
||||
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
|
||||
blend $= Disabled
|
||||
drawShader (_bloomBlurShader pdata) 4
|
||||
replicateM_ 3 $ pingPongBetween (_fboFourth1 pdata) (_fboFourth2 pdata) (_bloomBlurShader pdata)
|
||||
-- viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||
blend $= Enabled
|
||||
viewport $= (Position 0 0
|
||||
, divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||
|
||||
bindFramebuffer Framebuffer $= fst (_fboLighting pdata)
|
||||
--viewport $= (Position 0 0
|
||||
-- , divideSize (w ^. config . shadow_resolution) $ Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||
createLightMap pdata lightPoints nWalls nSils nsurfVs
|
||||
--viewport $= (Position 0 0, Size (round $ fstV2 wins) (round $ sndV2 wins))
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
clearColor $= Color4 0 0 0 0
|
||||
|
||||
@@ -138,8 +138,10 @@ doDrawing pdata w = do
|
||||
textureBinding Texture2D $= Just (snd $ _fboColor pdata)
|
||||
drawShader (_colorBlurShader pdata) 4
|
||||
--textureBinding Texture2D $= Just (snd3 $ _fbo2 pdata)
|
||||
--blendFunc $= (SrcAlpha, One)
|
||||
textureBinding Texture2D $= Just (snd $ _fboFourth1 pdata)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
|
||||
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@ sizeFBOs
|
||||
-> IO (RenderData)
|
||||
sizeFBOs xsize ysize xfull yfull rdata = do
|
||||
resizeRBO (_rboBaseBloom rdata) xsize ysize
|
||||
resizeRBO (_rboLighting rdata) xsize ysize
|
||||
rdata' <- foldM (updateFBOTO xsize ysize) rdata [fboBase, fboBloom, fboColor,fboFourth1,fboFourth2]
|
||||
rdata'' <- foldM (updateFBOTO xfull yfull) rdata' [fbo2, fbo3]
|
||||
updateFBOTO xsize ysize rdata'' fboLighting
|
||||
resizeRBO (_rboLighting rdata) xsize ysize
|
||||
rdata' <- foldM (updateFBOTO xsize ysize minMagFilter) rdata [fboBase, fboColor,fboLighting]
|
||||
rdata'' <- updateFBOTO xsize ysize minMagFilter rdata' fboBloom
|
||||
rdata''' <- foldM (updateFBOTO xfull yfull minMagFilter) rdata'' [fbo2, fbo3]
|
||||
foldM (updateFBOTO (xsize `div` 2) (ysize `div` 2) linMinMagFilter) rdata''' [fboFourth1,fboFourth2]
|
||||
|
||||
resizeRBO
|
||||
:: RenderbufferObject
|
||||
@@ -42,19 +43,21 @@ resizeRBO rboName xsize ysize = do
|
||||
updateFBOTO
|
||||
:: Int
|
||||
-> Int
|
||||
-> ((TextureFilter, Maybe TextureFilter),TextureFilter)
|
||||
-> RenderData
|
||||
-> ALens' RenderData (FramebufferObject, TextureObject)
|
||||
-> IO (RenderData)
|
||||
updateFBOTO xsize ysize pdata target = do
|
||||
newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize
|
||||
updateFBOTO xsize ysize mmfilt pdata target = do
|
||||
newfbo2 <- resizeFBOTO (pdata ^# target) xsize ysize mmfilt
|
||||
return $ storing target newfbo2 pdata
|
||||
|
||||
resizeFBOTO
|
||||
:: (FramebufferObject , TextureObject)
|
||||
-> Int
|
||||
-> Int
|
||||
-> ((TextureFilter, Maybe TextureFilter),TextureFilter)
|
||||
-> IO (FramebufferObject, TextureObject)
|
||||
resizeFBOTO (fboName,toOld) xsize ysize = do
|
||||
resizeFBOTO (fboName,toOld) xsize ysize mmfilt = do
|
||||
bindFramebuffer Framebuffer $= fboName
|
||||
let xsize' = fromIntegral xsize
|
||||
ysize' = fromIntegral ysize
|
||||
@@ -62,7 +65,7 @@ resizeFBOTO (fboName,toOld) xsize ysize = do
|
||||
toName <- genObjectName
|
||||
textureBinding Texture2D $= Just toName
|
||||
glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 xsize' ysize'
|
||||
textureFilter Texture2D $= minMagFilter
|
||||
textureFilter Texture2D $= mmfilt
|
||||
framebufferTexture2D Framebuffer (ColorAttachment 0) Texture2D toName 0
|
||||
fboStatus <- framebufferStatus Framebuffer
|
||||
putStrLn $ "after resize, framebuffer status:" ++ show fboStatus
|
||||
@@ -71,3 +74,5 @@ resizeFBOTO (fboName,toOld) xsize ysize = do
|
||||
minMagFilter :: ((TextureFilter, Maybe TextureFilter),TextureFilter)
|
||||
minMagFilter = ((Nearest,Nothing),Nearest)
|
||||
|
||||
linMinMagFilter :: ((TextureFilter, Maybe TextureFilter),TextureFilter)
|
||||
linMinMagFilter = ((Linear',Nothing),Linear')
|
||||
|
||||
@@ -34,7 +34,7 @@ renderDataResizeUpdate xsize ysize xfull yfull rdata = do
|
||||
bbFrag <- BS.readFile "shader/texture/bloomBlur.frag"
|
||||
let (bh,bmid) = BS.breakSubstring "(" bbFrag
|
||||
(_,btt) = BS.breakSubstring ")" bmid
|
||||
bbFrag' = BS.append bh $ BS.append (BSC.pack $ '(' : show xfull ++ "," ++ show yfull) btt
|
||||
bbFrag' = BS.append bh $ BS.append (BSC.pack $ '(' : show xsize ++ "," ++ show ysize) btt
|
||||
--BSC.putStrLn bbFrag'
|
||||
bbShad <- makeByteStringShaderUsingVAO "bloomBlur" [(vert,bbVert),(frag,bbFrag')] ETriangleStrip
|
||||
(_fullscreenShader rdata)
|
||||
|
||||
Reference in New Issue
Block a user