Last active
November 22, 2023 15:11
-
-
Save pingpoli/7f7f6fdf4096227f3895415568888030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 330 core | |
uniform sampler2D colorTexture; | |
uniform float resolution; | |
uniform float radius; | |
uniform vec2 direction; | |
in vec2 uv; | |
out vec4 fragColor; | |
void main() | |
{ | |
float blur = radius/resolution; | |
float hstep = direction.x; | |
float vstep = direction.y; | |
vec4 sum = texture2D( colorTexture , vec2( uv.x - 4.0*blur*hstep , uv.y - 4.0*blur*vstep )) * 0.0162162162; | |
sum += texture2D( colorTexture , vec2( uv.x - 3.0*blur*hstep , uv.y - 3.0*blur*vstep )) * 0.0540540541; | |
sum += texture2D( colorTexture , vec2( uv.x - 2.0*blur*hstep , uv.y - 2.0*blur*vstep )) * 0.1216216216; | |
sum += texture2D( colorTexture , vec2( uv.x - 1.0*blur*hstep , uv.y - 1.0*blur*vstep )) * 0.1945945946; | |
sum += texture2D( colorTexture , vec2( uv.x , uv.y )) * 0.2270270270; | |
sum += texture2D( colorTexture , vec2( uv.x + 1.0*blur*hstep , uv.y + 1.0*blur*vstep )) * 0.1945945946; | |
sum += texture2D( colorTexture , vec2( uv.x + 2.0*blur*hstep , uv.y + 2.0*blur*vstep )) * 0.1216216216; | |
sum += texture2D( colorTexture , vec2( uv.x + 3.0*blur*hstep , uv.y + 3.0*blur*vstep )) * 0.0540540541; | |
sum += texture2D( colorTexture , vec2( uv.x + 4.0*blur*hstep , uv.y + 4.0*blur*vstep )) * 0.0162162162; | |
fragColor = vec4( sum.rgb , 1.0 ); | |
} | |
/* | |
// the uniforms for the two gaussian blur passes | |
glUniform1f( u_resolution , width ); | |
glUniform2f( u_direction , 1.0f , 0.0f ); | |
// draw horizontal | |
glUniform1f( u_resolution , height ); | |
glUniform2f( u_direction , 0.0f , 1.0f ); | |
// draw vertical | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment