#version 460 core
in vec4 FragmentPosition;
uniform vec3 lightPosition;
uniform float farPlane;

void main()
{
    float lightDistance = length(FragmentPosition.xyz - lightPosition);
    
    // map to range [0;1] by dividing by far plane
    lightDistance = lightDistance / farPlane;
    
    // write this as modified depth
    gl_FragDepth = lightDistance;
}