Add trail to bloom

This commit is contained in:
jgk
2021-07-05 21:31:35 +02:00
parent 77d93fabeb
commit be7bf986e2
6 changed files with 28 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
#version 430 core
out vec4 fColor;
void main () { fColor = vec4(0,0,0,0.5);}
+4
View File
@@ -0,0 +1,4 @@
#version 430 core
layout (location = 0) in vec2 position;
void main()
{ gl_Position = vec4 (position, 0 , 1);}
+1 -1
View File
@@ -46,7 +46,7 @@ void main()
float alph = 0.0;
for (int i = 0; i < 9; i++)
alph += sampleTex[i].a;
alph = sampleTex[5].a + alph/9.0;
alph = max(sampleTex[4].a, alph/9.0);
//
//fColor = col;
fColor = vec4(col.rgb/col.a,alph);
+1
View File
@@ -16,6 +16,7 @@ data RenderData = RenderData
, _textureShader :: FullShader
, _textureArrayShader :: FullShader
, _fullscreenShader :: FullShader
, _fullscreenAlphaHalveShader :: FullShader
, _boxBlurShader :: FullShader
, _grayscaleShader :: FullShader
, _pictureShaders :: [FullShader]
+7 -1
View File
@@ -84,12 +84,18 @@ doDrawing pdata w = do
depthFunc $= Just Always
--blend $= Disabled
textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
clear [ColorBuffer]
--clear [ColorBuffer]
--blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
blendFuncSeparate $= ((Zero,One), (Zero,SrcAlpha))
bindShaderBuffers [_fullscreenAlphaHalveShader pdata] [4]
drawShader (_fullscreenAlphaHalveShader 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
--blend $= Enabled
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
+12
View File
@@ -47,6 +47,10 @@ preloadRender = do
cslist <- makeShader "twoD/character" [vert,frag] [3,4,2] ETriangles pokeCharStrat
>>= addTexture "data/texture/charMap.png"
basicTweakZShad <- makeShader "twoD/basicTweakZ" [vert,frag] [4,4] ETriangles pokeTriTweakZ
-- fullscreen shaders
fullscreenAlphaHalveShad <- makeShader "fullscreen/alphaHalve" [vert,frag] [2] ETriangleStrip $
const cornerListNoCoord
pokeArray (_vboPointer $ _vaoVBO $ _shaderVAO fullscreenAlphaHalveShad) $ concat cornerListNoCoord
-- texture shaders, no textures attached
fsShad <- makeShader "texture/simple" [vert,frag] [2,2] ETriangleStrip $ const cornerList
-- note we directly poke the shader vertex data here
@@ -103,6 +107,7 @@ preloadRender = do
, _textureShader = textShad
, _textureArrayShader = textArrayShad
, _fullscreenShader = fsShad
, _fullscreenAlphaHalveShader = fullscreenAlphaHalveShad
, _boxBlurShader = boxBlurShad
, _grayscaleShader = grayscaleShad
, _spareFBO = fbo
@@ -125,6 +130,13 @@ cornerList =
,[-1,-1,0,0]
,[ 1,-1,1,0]
]
cornerListNoCoord :: [[Float]]
cornerListNoCoord =
[[-1, 1]
,[ 1, 1]
,[-1,-1]
,[ 1,-1]
]
--------------------end preloadRender
setupFramebufferWithStencil :: IO (FramebufferObject, TextureObject,RenderbufferObject)