I am having a problem with a gaussian blur shader that I am working on. At present the shader works perfectly and give a nice even blur.
The problem I am having is when I try to send the radius to the shader through v_vAttributes.z, I get the following errors;
I'd like to be able to control the radius from the application so I can control it at runtime.
warning X3550: array reference cannot be used as an l-value; not natively addressable, forcing loop to unroll
warning X3550: array reference cannot be used as an l-value; not natively addressable, forcing loop to unroll
warning X3553: can't use gradient instructions in loops with break, forcing loop to unroll
error X4505: maximum temp register index exceeded
varying vec2 v_vTexcoord;
varying vec3 v_vAttributes;
void main()
{
float width=v_vAttributes.x;
float height=v_vAttributes.y;
float inRadius=20.0; //v_vAttributes.z; ** PROBLEM OCCURS HERE **
int inDiameter=(int(inRadius)*2)+1;
float gaussian_kernel[99];
float twoRadiusSquaredRecip=1.0/(2.0*inRadius*inRadius);
float sqrtTwoPiTimesRadiusRecip=1.0/(sqrt(2.0*3.141)*inRadius);
// Create Gaussian Kernel
float rr=-inRadius;
float sum=0.0;
for (int i=0;i<inDiameter;i++)
{
float v=sqrtTwoPiTimesRadiusRecip*exp(-rr*rr*twoRadiusSquaredRecip);
gaussian_kernel[i]=v;
sum+=v;
rr++;
}
// Normalize distribution
for (int i=0;i<inDiameter;i++)
gaussian_kernel[i]/=sum;
gl_FragColor = vec4(0.0);
for(int i=0;i<(inDiameter);i++)
gl_FragColor += texture2D(gm_BaseTexture, vec2(v_vTexcoord)-vec2(((float(inDiameter+i)-(float(inDiameter))/2.0)/width)-((inRadius*2.0)/width), 0.0))*gaussian_kernel[i];
}
I am the using GLSL ES shader model if that helps.Any advice would be greatly appreciated. :)