playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
3 lines (2 loc) • 2.89 kB
TypeScript
declare const _default: "\nvar sourceTexture: texture_2d<f32>;\nvar sourceTextureSampler: sampler;\nuniform sourceInvResolution: vec2f;\nvarying uv0: vec2f;\n\n#ifdef PREMULTIPLY\n var premultiplyTexture: texture_2d<f32>;\n var premultiplyTextureSampler: sampler;\n#endif\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n var output: FragmentOutput;\n\n let e: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, input.uv0).rgb);\n\n #ifdef BOXFILTER\n var value: half3 = e;\n\n #ifdef PREMULTIPLY\n let premultiply: half = half(textureSample(premultiplyTexture, premultiplyTextureSampler, input.uv0).{PREMULTIPLY_SRC_CHANNEL});\n value *= premultiply;\n #endif\n #else\n\n let x: f32 = uniform.sourceInvResolution.x;\n let y: f32 = uniform.sourceInvResolution.y;\n\n let a: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y + 2.0 * y)).rgb);\n let b: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y + 2.0 * y)).rgb);\n let c: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y + 2.0 * y)).rgb);\n\n let d: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y)).rgb);\n let f: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y)).rgb);\n\n let g: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y - 2.0 * y)).rgb);\n let h: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y - 2.0 * y)).rgb);\n let i: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y - 2.0 * y)).rgb);\n\n let j: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y + y)).rgb);\n let k: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y + y)).rgb);\n let l: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y - y)).rgb);\n let m: half3 = half3(textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y - y)).rgb);\n\n var value: half3 = e * half(0.125);\n value += (a + c + g + i) * half(0.03125);\n value += (b + d + f + h) * half(0.0625);\n value += (j + k + l + m) * half(0.125);\n #endif\n\n #ifdef REMOVE_INVALID\n value = max(value, half3(0.0));\n #endif\n\n output.color = vec4f(vec3f(value), 1.0);\n return output;\n}\n";
export default _default;