Vixen
02b45cc4
csharp
public static class CubeMap

Where a cube map's texels point, and how much sky each of them covers.

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

Remarks

Six faces in the order KTX2 and every graphics API store them: +X, −X, +Y, −Y, +Z, −Z. Within a face, u runs left to right and v runs top to bottom, which is the part that trips people: a cube face's second axis points down, so the mapping has minus signs in it that look like mistakes and are not.

A texel's solid angle is not constant. A cube is a bad sphere: the texel at the centre of a face covers noticeably more sky than the one at its corner, by a factor of about five at any reasonable size. Every integral over an environment — irradiance, prefiltering, the total energy in a probe — is wrong by that factor if it treats texels as equal, and wrong in a way that looks like a lighting bug rather than a geometry one. SolidAngleOfTexel is the correction, and the test that all of them sum to 4π is the check that it is right.

Fields and properties (1)

  • public const int Faces

    How many faces a cube map has.

Methods (8)

  • public static Vector3 DirectionOf(int face, float u, float v)

    Which way a point on a face points.

  • public static Vector3 DirectionOfTexel(int face, int x, int y, int size)

    Which way the centre of a texel points.

  • public static float SolidAngleOfTexel(int x, int y, int size)

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

  • public static (int Face, float U, float V) FaceOf(Vector3 direction)

    Which face and where on it a direction lands.

  • public static Vector3 Sample(TextureData cube, int level, Vector3 direction)

    Reads the texel a direction lands on.

  • public static Vector3 ReadTexel(TextureData cube, int level, int face, int x, int y)

    Reads one texel.

  • public static void WriteTexel(TextureData cube, int level, int face, int x, int y, Vector3 radiance)

    Writes one texel, leaving alpha at one.

  • public static void Require(TextureData cube, string name)

    Checks that a texture is a square cube map in a float format, and says what is wrong if not.

Used by (3)

  • EnvironmentPrefilterVixen.Core.Imaging
  • IblTestsVixen.Core.Imaging.Tests
  • SphericalHarmonicsL2Vixen.Core.Imaging