T
TaylorBramble
Guest
Hi all,
I'm working on shaders, specifically for a simple blur effect.
I am passing in a variable u_Blur to the shader, so that if I get hit or something, the screen blurs for a bit and gradually goes back down.
here's the code in my fragment:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float u_Blur;
void main()
{
vec4 Color;
float v;
for( float i=0.0;i<1.0;i+=1.0/ u_Blur )
{
v = 0.9+i*0.1;//convert "i" to the 0.9 to 1 range
Color += texture2D( gm_BaseTexture, v_vTexcoord*v+0.5-0.5*v);
}
Color /= float(u_Blur);
gl_FragColor = Color * v_vColour;
}
based off that guy Xor's tutorials.
Problem is, if I pass in the u_Blur value from my shader controller object, it says the for loop never finishes. To me, that doesn't make sense. I've got the blur_amount variable set to 16, so it should just do 16 iterations, I would think.
I know I'm passing it in correctly, since if i just use the number 16 in place of u_Blur, except for the line "Color /= float(u_Blur); it all works, blur and the color is affected just fine, I just obviously can't change the blur anymore.
Anybody see something wrong here?
New to shaders, so it might just be some bad syntax or something, sorry x.x
I'm working on shaders, specifically for a simple blur effect.
I am passing in a variable u_Blur to the shader, so that if I get hit or something, the screen blurs for a bit and gradually goes back down.
here's the code in my fragment:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float u_Blur;
void main()
{
vec4 Color;
float v;
for( float i=0.0;i<1.0;i+=1.0/ u_Blur )
{
v = 0.9+i*0.1;//convert "i" to the 0.9 to 1 range
Color += texture2D( gm_BaseTexture, v_vTexcoord*v+0.5-0.5*v);
}
Color /= float(u_Blur);
gl_FragColor = Color * v_vColour;
}
based off that guy Xor's tutorials.
Problem is, if I pass in the u_Blur value from my shader controller object, it says the for loop never finishes. To me, that doesn't make sense. I've got the blur_amount variable set to 16, so it should just do 16 iterations, I would think.
I know I'm passing it in correctly, since if i just use the number 16 in place of u_Blur, except for the line "Color /= float(u_Blur); it all works, blur and the color is affected just fine, I just obviously can't change the blur anymore.
Anybody see something wrong here?
New to shaders, so it might just be some bad syntax or something, sorry x.x