playcanvas
Version:
PlayCanvas WebGL game engine
51 lines (48 loc) • 1.28 kB
JavaScript
var litShadowMainPS = `
uniform view_position: vec3f;
uniform light_radius: f32;
@fragment
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
var output: FragmentOutput;
evaluateFrontend();
var depth: f32 = input.position.z;
depth = linearizeDepthWithParams(depth, camera_params);
var depth: f32 = min(distance(uniform.view_position, input.vPositionW) / uniform.light_radius, 0.99999);
var exponent: f32 = 15.0;
var exponent: f32 = 5.54;
var depth_vsm = 2.0 * depth - 1.0;
depth_vsm = exp(exponent * depth_vsm);
output.color = vec4f(depth_vsm, depth_vsm * depth_vsm, 1.0, 1.0);
output.color = vec4f(depth, 0.0, 0.0, 1.0);
output.fragDepth = depth;
output.color = vec4f(1.0);
return output;
}
`;
export { litShadowMainPS as default };