playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
68 lines (56 loc) • 1.76 kB
JavaScript
var litShadowMain_default = (
/* glsl */
`
uniform vec3 view_position;
uniform float light_radius;
void main(void) {
evaluateFrontend();
// using non-standard depth, i.e gl_FragCoord.z
float depth = gl_FragCoord.z;
// spot/omni shadows currently use linear depth.
// TODO: use perspective depth for spot/omni the same way as directional
depth = linearizeDepthWithParams(depth, camera_params);
float depth = min(distance(view_position, vPositionW) / light_radius, 0.99999);
float exponent = 15.0;
float exponent = 5.54;
depth = 2.0 * depth - 1.0;
depth = exp(exponent * depth);
gl_FragColor = vec4(depth, depth*depth, 1.0, 1.0);
// store depth into R32
gl_FragColor.r = depth;
// If we end up using modified depth, it needs to be explicitly written to gl_FragDepth
gl_FragDepth = depth;
// just the simplest code, color is not written anyway
gl_FragColor = vec4(1.0);
}
`
);
export {
litShadowMain_default as default
};