playcanvas
Version:
PlayCanvas WebGL game engine
31 lines (29 loc) • 815 B
JavaScript
var blurVSMPS = `
varying vUv0: vec2f;
var source: texture_2d<f32>;
var sourceSampler: sampler;
uniform weight: array<f32, {SAMPLES}>;
uniform pixelOffset: vec2f;
@fragment
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
var output: FragmentOutput;
var moments: vec3f = vec3f(0.0);
let uv: vec2f = input.vUv0 - uniform.pixelOffset * (f32({SAMPLES}) * 0.5);
for (var i: i32 = 0; i < {SAMPLES}; i = i + 1) {
let c: vec4f = textureSample(source, sourceSampler, uv + uniform.pixelOffset * f32(i));
moments = moments + c.xyz * uniform.weight[i].element;
moments = moments + c.xyz;
}
moments = moments * (1.0 / f32({SAMPLES}));
output.color = vec4f(moments, 1.0);
return output;
}
`;
export { blurVSMPS as default };