playcanvas
Version:
PlayCanvas WebGL game engine
101 lines (82 loc) • 2.75 kB
JavaScript
var composePS = /* wgsl */ `
varying uv0: vec2f;
var sceneTexture: texture_2d<f32>;
var sceneTextureSampler: sampler;
uniform sceneTextureInvRes: vec2f;
@fragment
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
var output: FragmentOutput;
var uv = uv0;
// TAA pass renders upside-down on WebGPU, flip it here
uv.y = 1.0 - uv.y;
let scene = textureSampleLevel(sceneTexture, sceneTextureSampler, uv, 0.0);
var result = scene.rgb;
// Apply CAS
result = applyCas(result, uv, uniform.sharpness);
// Apply DOF
result = applyDof(result, uv0);
// Apply SSAO
result = applySsao(result, uv0);
// Apply Fringing
result = applyFringing(result, uv);
// Apply Bloom
result = applyBloom(result, uv0);
// Apply Color Grading
result = applyGrading(result);
// Apply Tone Mapping
result = toneMap(result);
// Apply Color LUT after tone mapping, in LDR space
result = applyColorLUT(result);
// Apply Vignette
result = applyVignette(result, uv);
// Debug output handling in one centralized location
result = scene.rgb;
result = dBloom * uniform.bloomIntensity;
result = vec3f(dCoc, 0.0);
result = dBlur;
result = vec3f(dSsao);
result = vec3f(dVignette);
// Apply gamma correction
result = gammaCorrectOutput(result);
output.color = vec4f(result, scene.a);
return output;
}
`;
export { composePS as default };