precision mediump float; uniform sampler2D uNormal; uniform sampler2D uBlur; uniform sampler2D uOcclusion; varying vec2 fUV; void main() { float occ = texture2D(uOcclusion, fUV).x; vec4 normalColor = texture2D(uNormal, fUV); // Tint the transparent parts of the source image with white if (normalColor.w < 1.0) { normalColor.xyz = (normalColor.xyz * normalColor.w) + (vec3(1.0, 1.0, 1.0) * (1.0 - normalColor.w)); normalColor.w = 1.0; } if (occ >= 1.0) { gl_FragColor = normalColor; } else if (occ <= 0.0) { gl_FragColor = texture2D(uBlur, fUV); } else { gl_FragColor.xyz = (normalColor.xyz * occ) + (texture2D(uBlur, fUV).xyz * (1.0 - occ)); } gl_FragColor.w = 1.0; }