Add trail to bloom

This commit is contained in:
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; float alph = 0.0;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
alph += sampleTex[i].a; alph += sampleTex[i].a;
alph = sampleTex[5].a + alph/9.0; alph = max(sampleTex[4].a, alph/9.0);
// //
//fColor = col; //fColor = col;
fColor = vec4(col.rgb/col.a,alph); fColor = vec4(col.rgb/col.a,alph);
+1
View File
@@ -16,6 +16,7 @@ data RenderData = RenderData
, _textureShader :: FullShader , _textureShader :: FullShader
, _textureArrayShader :: FullShader , _textureArrayShader :: FullShader
, _fullscreenShader :: FullShader , _fullscreenShader :: FullShader
, _fullscreenAlphaHalveShader :: FullShader
, _boxBlurShader :: FullShader , _boxBlurShader :: FullShader
, _grayscaleShader :: FullShader , _grayscaleShader :: FullShader
, _pictureShaders :: [FullShader] , _pictureShaders :: [FullShader]
+7 -1
View File
@@ -84,12 +84,18 @@ doDrawing pdata w = do
depthFunc $= Just Always depthFunc $= Just Always
--blend $= Disabled --blend $= Disabled
textureBinding Texture2D $= Just (snd $ _fboBloom pdata) textureBinding Texture2D $= Just (snd $ _fboBloom pdata)
clear [ColorBuffer] --clear [ColorBuffer]
--blendFunc $= (SrcAlpha,OneMinusSrcAlpha) --blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
blendFuncSeparate $= ((Zero,One), (Zero,SrcAlpha))
bindShaderBuffers [_fullscreenAlphaHalveShader pdata] [4]
drawShader (_fullscreenAlphaHalveShader pdata) 4
blendFunc $= (One,Zero) blendFunc $= (One,Zero)
bindShaderBuffers [_boxBlurShader pdata] [4] bindShaderBuffers [_boxBlurShader pdata] [4]
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
drawShader (_boxBlurShader pdata) 4 drawShader (_boxBlurShader pdata) 4
blendFunc $= (One,Zero)
pingPongBlur pdata pingPongBlur pdata
replicateM_ 5 $ pingPongBlur pdata
--blend $= Enabled --blend $= Enabled
blendFunc $= (SrcAlpha,OneMinusSrcAlpha) blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
+12
View File
@@ -47,6 +47,10 @@ preloadRender = do
cslist <- makeShader "twoD/character" [vert,frag] [3,4,2] ETriangles pokeCharStrat cslist <- makeShader "twoD/character" [vert,frag] [3,4,2] ETriangles pokeCharStrat
>>= addTexture "data/texture/charMap.png" >>= addTexture "data/texture/charMap.png"
basicTweakZShad <- makeShader "twoD/basicTweakZ" [vert,frag] [4,4] ETriangles pokeTriTweakZ 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 -- texture shaders, no textures attached
fsShad <- makeShader "texture/simple" [vert,frag] [2,2] ETriangleStrip $ const cornerList fsShad <- makeShader "texture/simple" [vert,frag] [2,2] ETriangleStrip $ const cornerList
-- note we directly poke the shader vertex data here -- note we directly poke the shader vertex data here
@@ -103,6 +107,7 @@ preloadRender = do
, _textureShader = textShad , _textureShader = textShad
, _textureArrayShader = textArrayShad , _textureArrayShader = textArrayShad
, _fullscreenShader = fsShad , _fullscreenShader = fsShad
, _fullscreenAlphaHalveShader = fullscreenAlphaHalveShad
, _boxBlurShader = boxBlurShad , _boxBlurShader = boxBlurShad
, _grayscaleShader = grayscaleShad , _grayscaleShader = grayscaleShad
, _spareFBO = fbo , _spareFBO = fbo
@@ -125,6 +130,13 @@ cornerList =
,[-1,-1,0,0] ,[-1,-1,0,0]
,[ 1,-1,1,0] ,[ 1,-1,1,0]
] ]
cornerListNoCoord :: [[Float]]
cornerListNoCoord =
[[-1, 1]
,[ 1, 1]
,[-1,-1]
,[ 1,-1]
]
--------------------end preloadRender --------------------end preloadRender
setupFramebufferWithStencil :: IO (FramebufferObject, TextureObject,RenderbufferObject) setupFramebufferWithStencil :: IO (FramebufferObject, TextureObject,RenderbufferObject)