decodeSurfaceNormal function
DecodeOctahedral, the inverse of what the surface buffer stored.
Implementation
Vector3 decodeSurfaceNormal(double ex, double ey) {
final x = ex * 2.0 - 1.0;
final y = ey * 2.0 - 1.0;
final n = Vector3(x, y, 1.0 - x.abs() - y.abs());
final t = math.max(-n.z, 0.0);
n.x += n.x >= 0.0 ? -t : t;
n.y += n.y >= 0.0 ? -t : t;
return n..normalize();
}