Changed blur of flames to gaussian blur.
This commit is contained in:
parent
4eb328d09d
commit
c7358e6efc
@ -5,17 +5,38 @@ in vec2 vTexCoord;
|
||||
uniform sampler2D light_fbo;
|
||||
uniform int windowSizeX;
|
||||
uniform int windowSizeY;
|
||||
uniform bool verticalPass;
|
||||
|
||||
out vec4 oColor;
|
||||
|
||||
const float lookup_offset = 4.0;
|
||||
//const float lookup_offset = 4.0;
|
||||
const float stretching = 2.0;
|
||||
|
||||
void main() {
|
||||
vec4 sum = vec4(0.0);
|
||||
for(float i = -lookup_offset; i<=lookup_offset; i+=1.0) {
|
||||
for(float j = -lookup_offset; j<=lookup_offset; j+=1.0) {
|
||||
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);
|
||||
if (verticalPass){
|
||||
float blurSize = 1.0/(float(windowSizeY)/(stretching));
|
||||
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;
|
||||
}
|
||||
|
@ -350,6 +350,9 @@ void Graphics::render(double time)
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
flamePostShader->use();
|
||||
flamePostShader->setUniform("verticalPass", true);
|
||||
fullscreen_quad->render();
|
||||
flamePostShader->setUniform("verticalPass", false);
|
||||
fullscreen_quad->render();
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
Loading…
Reference in New Issue
Block a user