public static class OctahedralMapThe whole sphere of directions as a square of texels, and back.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The same fold as Math.EncodeOctahedral in the Raven library, and that is a contract rather than a coincidence. A screen probe's radiance map is written by one side and read by the other, so the direction a texel stands for has to be one function evaluated twice. The shader's version exists first (it encodes G-buffer normals); this is its C# counterpart, with the tie at zero broken the same way — a zero component picks the positive hemisphere — because a convention that differs only on a set of measure zero is exactly the kind that passes every test until a probe sits on an axis.
Solid angles are computed exactly, not approximated by a Jacobian at the texel centre. A projection into spherical harmonics is an integral, so every texel has to carry the area of sphere it stands for — SphericalHarmonicsL1.Accumulated says the same thing from the other side. The octahedral map is not equal-area, and the error of a centre-point approximation is largest exactly where the map distorts most, which is where a cheap answer would bias every probe the same way and nobody would trace it back. A texel maps to a spherical polygon whose edges are great-circle arcs within one octant — the pre-normalisation point is affine in the plane there — so the exact answer is: clip the texel against the eight octants, map each piece's corners, and sum the spherical polygon areas. The test that keeps this honest is that the texels of any resolution sum to 4π at double precision.
Methods (7)
public static Vector2 Encode(Vector3 direction)Folds a direction into the octahedral square.
public static Vector3 Decode(Vector2 encoded)Unfolds a point of the square back into a direction.
public static Vector2 TexelCentre(Int2 texel, int resolution)Where a texel's centre sits in the square.
public static Vector3 Direction(Int2 texel, int resolution)The direction a texel's centre stands for.
public static Int2 Texel(Vector3 direction, int resolution)The texel a direction lands in.
public static ReadOnlyMemory<float> SolidAngles(int resolution)How much of the sphere each texel of a map stands for.
public static float SolidAngle(Int2 texel, int resolution)How much of the sphere one texel stands for.
Used by (8)
- AccelerationStructureDeviceTestsVixen.Graphics.Golden.Tests
- AtlasConventionTestsVixen.Rendering.ScreenProbes.Tests
- CornellBoxTestsVixen.Rendering.SurfaceCache.Tests
- OctahedralMapTestsVixen.Rendering.ScreenProbes.Tests
- ScreenProbeAtlasVixen.Rendering.ScreenProbes
- ScreenProbeResolveVixen.Rendering
- ScreenSpaceTraceTestsVixen.Rendering.ScreenProbes.Tests
- TracedScreenProbeGatherVixen.Rendering.ScreenProbes