Guys .... I found this code ... But I need to convert it to AppGameKit
#ifdef GL_ESprecision highp float;
#endif
uniform sampler2D textureSampler;
uniform sampler2D depthSampler;
uniform float focus_depth;
varying vec2 vUV;
vec4 sampleBox(float u, float v, float size)
{
vec4 color = vec4(0.0,0.0,0.0,0.0);
color += texture2D(textureSampler, vec2(vUV.x - size, vUV.y - size)) * 0.075;
color += texture2D(textureSampler, vec2(vUV.x, vUV.y - size)) * 0.1;
color += texture2D(textureSampler, vec2(vUV.x + size, vUV.y - size)) * 0.075;
color += texture2D(textureSampler, vec2(vUV.x - size, vUV.y)) * 0.1;
color += texture2D(textureSampler, vec2(vUV.x, vUV.y)) * 0.30;
color += texture2D(textureSampler, vec2(vUV.x + size, vUV.y)) * 0.1;
color += texture2D(textureSampler, vec2(vUV.x - size, vUV.y + size)) * 0.075;
color += texture2D(textureSampler, vec2(vUV.x, vUV.y + size)) * 0.1;
color += texture2D(textureSampler, vec2(vUV.x + size, vUV.y + size)) * 0.075;
return color;
}
void main(void)
{
float depth = texture2D(depthSampler, vUV).r;
float blur_amount = abs(depth-focus_depth)*20.0;
if(depth < depth-focus_depth) { blur_amount *= 10.0; }
blur_amount = clamp(blur_amount, 0.0, 1.0);
vec4 baseColor = texture2D(textureSampler, vUV);
vec4 blurredColor = vec4(0.0,0.0,0.0,0.0);
float blurSize = 0.005*blur_amount;
blurredColor = 0.75*sampleBox(vUV.x, vUV.y, blurSize*0.5) + 0.25*sampleBox(vUV.x, vUV.y, blurSize*1.0);
gl_FragColor = baseColor * (1.0 - blur_amount) + blurredColor * blur_amount;
}