eyeDistance function
EyeDistance: how far this fragment is from the camera, in world metres.
What the fog fades by. A distance, because fog is a property of the air between two points and does not care which way the camera faces — through a perspective lens. Through an orthographic one, the depth from the eye's plane, as the GLSL has it.
Implementation
double eyeDistance(Float32List v, ShaderBindings b) {
if (orthographic(b)) return math.max(viewDepth(v, b), 0.0);
final eye = b.vec4('FogInfo', 'eye', Vector4.zero());
final dx = v[kVWorld] - eye.x;
final dy = v[kVWorld + 1] - eye.y;
final dz = v[kVWorld + 2] - eye.z;
return math.sqrt(dx * dx + dy * dy + dz * dz);
}