fogDistance function
FogDistance of contributor_eye.glsl: the air between a point and the
eye — the distance to it, or the depth from its plane through an
orthographic lens.
Implementation
double fogDistance(ShaderBindings b, double x, double y, double z) {
final eye = b.vec4('FogInfo', 'eye', Vector4.zero());
final dx = x - eye.x;
final dy = y - eye.y;
final dz = z - eye.z;
if (!orthographic(b)) return math.sqrt(dx * dx + dy * dy + dz * dz);
final forward = b.vec4('FogInfo', 'forward', Vector4.zero());
return math.max(dx * forward.x + dy * forward.y + dz * forward.z, 0.0);
}