playcanvas
Version:
PlayCanvas WebGL game engine
3 lines (2 loc) • 2.06 kB
TypeScript
declare const _default: "\n #if defined(NEAR_BLUR)\n uniform sampler2D nearTexture;\n #endif\n uniform sampler2D farTexture;\n uniform sampler2D cocTexture;\n\n uniform vec2 kernel[{KERNEL_COUNT}];\n uniform float blurRadiusNear;\n uniform float blurRadiusFar;\n\n varying vec2 uv0;\n\n void main()\n {\n vec2 coc = texture2D(cocTexture, uv0).rg;\n float cocFar = coc.r;\n\n vec3 sum = vec3(0.0, 0.0, 0.0);\n\n #if defined(NEAR_BLUR)\n // near blur\n float cocNear = coc.g;\n if (cocNear > 0.0001) {\n\n ivec2 nearTextureSize = textureSize(nearTexture, 0);\n vec2 step = cocNear * blurRadiusNear / vec2(nearTextureSize);\n\n for (int i = 0; i < {KERNEL_COUNT}; i++) {\n vec2 uv = uv0 + step * kernel[i];\n vec3 tap = texture2DLod(nearTexture, uv, 0.0).rgb;\n sum += tap.rgb;\n }\n\n sum *= float({INV_KERNEL_COUNT});\n\n } else\n #endif\n \n if (cocFar > 0.0001) { // far blur\n\n ivec2 farTextureSize = textureSize(farTexture, 0);\n vec2 step = cocFar * blurRadiusFar / vec2(farTextureSize);\n\n float sumCoC = 0.0; \n for (int i = 0; i < {KERNEL_COUNT}; i++) {\n vec2 uv = uv0 + step * kernel[i];\n vec3 tap = texture2DLod(farTexture, uv, 0.0).rgb;\n\n // block out sharp objects to avoid leaking to far blur\n float cocThis = texture2DLod(cocTexture, uv, 0.0).r;\n tap *= cocThis;\n sumCoC += cocThis;\n\n sum += tap;\n }\n\n // average out the sum\n if (sumCoC > 0.0)\n sum /= sumCoC;\n\n // compensate for the fact the farTexture was premultiplied by CoC\n sum /= cocFar;\n }\n\n pcFragColor0 = vec4(sum, 1.0);\n }\n";
export default _default;