Vixen
02b45cc4
csharp
public static class CubeMapping

Which direction a cube-map texel looks in, and which texel a direction lands on.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Everything that bakes an environment needs this: a spherical-harmonic projection walks every texel and asks where it points, and a prefilter pass walks the hemisphere and asks which texel a sample lands on. Both have to agree with the convention the GPU uses, or an environment comes out mirrored, rotated by ninety degrees, or subtly wrong at the seams — none of which looks like a bug in a bake.

The convention is not invented here. Direction is derived from Cube by unprojecting the face's own matrix, which is the same matrix a point light renders its shadow cube with and which is already asserted to tile the sphere with no gap and no overlap. Two conventions in one engine is how a probe ends up disagreeing with a shadow, so there is one.

Locate is the inverse, and it is the major-axis rule rather than six matrix multiplies — a prefilter takes millions of samples. That makes it a second implementation of the same idea, which is exactly the shape that drifts, so a test holds it against the unprojection over thousands of random directions.

Fields and properties (1)

  • public static readonly CubeFace[] Faces

    The six faces, in layer order.

Methods (3)

  • public static Vector3 Direction(CubeFace face, float u, float v)

    Where a point on a face looks, as a unit vector.

  • public static (CubeFace Face, float U, float V) Locate(Vector3 direction)

    Which face a direction lands on, and where on it.

  • public static float SolidAngle(float u, float v, float size)

    How much of the sphere one texel covers, in steradians.

Used by (7)

  • CubeImageVixen.Rendering
  • EnvironmentBakerVixen.Rendering
  • EnvironmentLightingTestsVixen.Rendering.Tests
  • IrradianceBounceDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceCaptureDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceCubeCaptureVixen.Rendering
  • SphericalHarmonicsVixen.Rendering