UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

3 lines (2 loc) 2.79 kB
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: vec3f = textureSample(sourceTexture, sourceTextureSampler, input.uv0).rgb;\n\n #ifdef BOXFILTER\n var value: vec3f = e;\n\n #ifdef PREMULTIPLY\n let premultiply: f32 = textureSample(premultiplyTexture, premultiplyTextureSampler, input.uv0).{PREMULTIPLY_SRC_CHANNEL};\n value = value * vec3f(premultiply);\n #endif\n #else\n\n let x: f32 = uniform.sourceInvResolution.x;\n let y: f32 = uniform.sourceInvResolution.y;\n\n let a: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y + 2.0 * y)).rgb;\n let b: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y + 2.0 * y)).rgb;\n let c: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y + 2.0 * y)).rgb;\n\n let d: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y)).rgb;\n let f: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y)).rgb;\n\n let g: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - 2.0 * x, input.uv0.y - 2.0 * y)).rgb;\n let h: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x, input.uv0.y - 2.0 * y)).rgb;\n let i: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + 2.0 * x, input.uv0.y - 2.0 * y)).rgb;\n\n let j: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y + y)).rgb;\n let k: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y + y)).rgb;\n let l: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x - x, input.uv0.y - y)).rgb;\n let m: vec3f = textureSample(sourceTexture, sourceTextureSampler, vec2f(input.uv0.x + x, input.uv0.y - y)).rgb;\n\n var value: vec3f = e * 0.125;\n value = value + (a + c + g + i) * 0.03125;\n value = value + (b + d + f + h) * 0.0625;\n value = value + (j + k + l + m) * 0.125;\n #endif\n\n #ifdef REMOVE_INVALID\n value = max(value, vec3f(0.0));\n #endif\n\n output.color = vec4f(value, 1.0);\n return output;\n}\n"; export default _default;