playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
52 lines (50 loc) • 1.3 kB
JavaScript
var litShadowMain_default = `
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 {
litShadowMain_default as default
};