Skip to main content

octahedral_encode

Function octahedral_encode 

Source
fn octahedral_encode(normal: Vec3) -> Vec2
Expand description

Octahedral-encode a unit normal into two [-1, 1] lanes.

The octahedral map folds the sphere onto a square: a direction is projected along z onto the octahedron’s upper half, and the lower half is folded over by mirroring about the diagonal. Every direction lands on a distinct point of the square with no pole singularity, which is why two lanes suffice for a normal where a plain xy projection would lose the hemisphere it folds.