towardsEye function
TowardsEye — P7: back along the ray that reached this fragment, to
the eye through a perspective lens and against the view axis through an
orthographic one.
Implementation
Vector3 towardsEye(Float32List v, ShaderBindings b) {
if (orthographic(b)) {
final forward = b.vec4('FogInfo', 'forward', Vector4.zero());
return Vector3(-forward.x, -forward.y, -forward.z);
}
final eye = b.vec4('FogInfo', 'eye', Vector4.zero());
return Vector3(
eye.x - v[kVWorld],
eye.y - v[kVWorld + 1],
eye.z - v[kVWorld + 2],
)..normalize();
}