Changed blur of flames to gaussian blur.

This commit is contained in:
Faerbit 2015-03-05 00:00:31 +01:00
parent 4eb328d09d
commit c7358e6efc
2 changed files with 29 additions and 5 deletions

View File

@ -5,17 +5,38 @@ in vec2 vTexCoord;
uniform sampler2D light_fbo; uniform sampler2D light_fbo;
uniform int windowSizeX; uniform int windowSizeX;
uniform int windowSizeY; uniform int windowSizeY;
uniform bool verticalPass;
out vec4 oColor; out vec4 oColor;
const float lookup_offset = 4.0; //const float lookup_offset = 4.0;
const float stretching = 2.0;
void main() { void main() {
vec4 sum = vec4(0.0); vec4 sum = vec4(0.0);
for(float i = -lookup_offset; i<=lookup_offset; i+=1.0) { if (verticalPass){
for(float j = -lookup_offset; j<=lookup_offset; j+=1.0) { float blurSize = 1.0/(float(windowSizeY)/(stretching));
sum += texture(light_fbo, vec2(vTexCoord.x + i * 1.0/(windowSizeX/2.0), vTexCoord.y + j * 1.0/(windowSizeY/2.0)))/pow(lookup_offset*2+1, 2.0); sum += texture(light_fbo, vec2(vTexCoord.x - 4.0*blurSize, vTexCoord.y)) * 0.05;
} sum += texture(light_fbo, vec2(vTexCoord.x - 3.0*blurSize, vTexCoord.y)) * 0.09;
sum += texture(light_fbo, vec2(vTexCoord.x - 2.0*blurSize, vTexCoord.y)) * 0.12;
sum += texture(light_fbo, vec2(vTexCoord.x - blurSize, vTexCoord.y)) * 0.15;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y)) * 0.16;
sum += texture(light_fbo, vec2(vTexCoord.x + blurSize, vTexCoord.y)) * 0.15;
sum += texture(light_fbo, vec2(vTexCoord.x + 2.0*blurSize, vTexCoord.y)) * 0.12;
sum += texture(light_fbo, vec2(vTexCoord.x + 3.0*blurSize, vTexCoord.y)) * 0.09;
sum += texture(light_fbo, vec2(vTexCoord.x + 4.0*blurSize, vTexCoord.y)) * 0.05;
}
else {
float blurSize = 1.0/(float(windowSizeX)/stretching);
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y - 4.0*blurSize)) * 0.05;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y - 3.0*blurSize)) * 0.09;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y - 2.0*blurSize)) * 0.12;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y - blurSize)) * 0.15;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y)) * 0.16;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y + blurSize)) * 0.15;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y + 2.0*blurSize)) * 0.12;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y + 3.0*blurSize)) * 0.09;
sum += texture(light_fbo, vec2(vTexCoord.x, vTexCoord.y + 4.0*blurSize)) * 0.05;
} }
oColor = sum; oColor = sum;
} }

View File

@ -350,6 +350,9 @@ void Graphics::render(double time)
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
flamePostShader->use(); flamePostShader->use();
flamePostShader->setUniform("verticalPass", true);
fullscreen_quad->render();
flamePostShader->setUniform("verticalPass", false);
fullscreen_quad->render(); fullscreen_quad->render();
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);