Hi,
I am trying to learn about shader development because I need blur effect.
I found some tutoriais and concepts about blur, like move some pixel and with alpha make a blur effect, after my research about theme I tried this code
varying mediump vec4 position;
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D DIFFUSE_TEXTURE;
void main()
{
float blur = 1.2;
float vstep = 1.0;
float hstep = 0.0;
vec4 texturesSums = vec4(0.0);
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -4.0*blur*vstep, var_texcoord0.y -4.0*blur*hstep)) * 0.0162162162;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -3.0*blur*vstep, var_texcoord0.y -3.0*blur*hstep)) * 0.0540540541;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -2.0*blur*vstep, var_texcoord0.y -2.0*blur*hstep)) * 0.1216216216;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -1.0*blur*vstep, var_texcoord0.y -1.0*blur*hstep)) * 0.1945945946;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x, var_texcoord0.y)) * 0.1;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -4.0*blur*hstep, var_texcoord0.y -4.0*blur*vstep)) * 0.1945945946;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -3.0*blur*hstep, var_texcoord0.y -3.0*blur*vstep)) * 0.1216216216;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -2.0*blur*hstep, var_texcoord0.y -2.0*blur*vstep)) * 0.0540540541;
texturesSums += texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x -1.0*blur*hstep, var_texcoord0.y -1.0*blur*vstep)) * 0.0162162162;
gl_FragColor = 3.0* vec4(texturesSums.rgb, 1.0);
}
When I run this shader it’s only run a image with alpha without blur
Sorry my dumb quest but It is my first contact with shaders…
Thanks advanced.
Victor C Tavernari