The problem I was having as I was trying to use a rendered image incorrectly but when I tested by loading an image it worked perfectly well
My personal preference is to create shaders within the code this helps with debugging when modifications are being done
but I changed the code to include a uniform size variable which allows for setting the resolution and the blur amount but then needs the
SetShaderConstantByName command to be called to take effect before it didn't
Snippet
createShader()
LoadSpriteShader(1,"blurr.ps")
//img=LoadImage("noise.png")
sprite=CreateSprite(img)
SetSpriteSize(sprite,1024,768)
SetShaderConstantByName(1,"size",1024.0,768.0,2.0,0.0) //x sprite size, y sprite size, blur ammout ,0.0 needed
SetSpriteShader(sprite,1)
do
Sync()
loop
CreateShader
function createShader()
file = OpenToWrite("blurr.ps")
WriteLine(file,"uniform sampler2D texture0;")
WriteLine(file,"varying mediump vec2 uvVarying;")
WriteLine(file,"varying mediump vec4 colorVarying;")
WriteLine(file,"uniform vec4 size; // ")
WriteLine(file,"mediump vec2 uOff = vec2(1.0/size.x,0.0); // these can be changed to match the size of the texture/pixel size")
WriteLine(file,"mediump vec2 vOff = vec2(0.0,1.0/size.y);")
WriteLine(file,"//float size = 1.0; // 5 gives 100 samples used to get ONE pixel! (2x5x2x5 = 100)")
WriteLine(file,"float x;")
WriteLine(file,"float y;")
WriteLine(file,"float mult= 1.0/4.0/size.z/size.z; //scale factor")
WriteLine(file,"void main()")
WriteLine(file,"{")
WriteLine(file," for (y = -size.z; y<size.z; y++) // a range of 2*size on y")
WriteLine(file," {")
WriteLine(file," for (x = -size.z; x<size.z; x++) // a range of 2*size on x")
WriteLine(file," {")
WriteLine(file," gl_FragColor += texture2D(texture0, uvVarying+(x*uOff)+(y*vOff)); ")
WriteLine(file," }")
WriteLine(file," }")
WriteLine(file," gl_FragColor *= mult; // scale the colour down by 1/100th as we have added up 100 pxels worth!")
WriteLine(file,"}")
CloseFile(file)
endfunction
Definitely very useful code Bengismofubar