well there was a bug in the shader code that fortunately I could find a solution for, so here is a working example that toggles between blurred and not blurred:
First, put this code into a file called: nornalblur.ps and put that into the media folder.
uniform sampler2D texture0;
varying vec2 posVarying;
varying vec2 uvVarying;
uniform vec2 agk_resolution;
uniform float BlurSize;
void main()
{
float blurSizeH = BlurSize / agk_resolution.x;
float blurSizeV = BlurSize / agk_resolution.y;
vec4 sum = vec4(0.0);
for (float x = -4.0; x <= 4.0; x++)
for (float y = -4.0; y <= 4.0; y++)
sum += texture2D(texture0,vec2(uvVarying.x + x * blurSizeH, uvVarying.y + y * blurSizeV))/ 81.0;
gl_FragColor = sum;
}
Note that the assignment of values to blurSizeH and V must be within the main() or it wont compile on Android.
and the AppGameKit code:
BGImage = loadimage("img_1517.jpg") // substitute your own file that is also in media folder
BGSprite = CreateSprite(BGImage)
SetSpriteSize(BGSprite,100,100)
NormalBlur=LoadSpriteShader("normalblur.ps")
blursize# = 1
shadertoggle = 1
SetSpriteShader(BGSprite, NormalBlur)
AddVirtualButton( 1, 10, 10, 10)
do
If GetVirtualButtonPressed(1)
if shadertoggle = 1
shadertoggle=0
setShaderConstantByName(NormalBlur, "BlurSize", 0 ,0,0,0) // zero blur
else
shadertoggle = 1
setShaderConstantByName(NormalBlur, "BlurSize", blursize# ,0,0,0)
endif
endif
Sync()
loop
Use your own file as a background image