Vixen
02b45cc4
csharp
public readonly record struct MipOptions

What a texture's contents mean, for the purpose of averaging them.

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

Remarks

A box filter is the same arithmetic whatever a texture holds, and it is the right arithmetic for almost none of them. Colour has to be averaged in linear light, a cut-out's invisible texels must not vote on the colour of its visible ones, and a normal is a direction rather than three numbers. None of that can be worked out from the pixel format: a normal map and an albedo map are both Rgba8UNorm, and a mask packed into an sRGB format is neither.

So it is a setting the caller supplies, which in practice is the importer reading it from a .meta file. That is the same division MipChain already draws for the transfer function, and this is where it is written down.

Fields and properties (7)

  • public bool Srgb

    Average in linear light rather than on the stored values. Right for colour; wrong for a normal map, a roughness map or a mask that happens to live in an sRGB format.

  • public bool AlphaWeighted

    Weight each texel's colour by its alpha. Right for a cut-out or a texture with unused regions; the colour under a fully transparent texel is usually whatever the painter left there, and it should not get a vote.

  • public bool RenormaliseNormals

    Treat the first two or three channels as a unit vector: reconstruct, average, normalise. The average of four unit vectors is not a unit vector, and a normal map whose mips are shorter than one lights as though the surface were flatter than it is.

  • public static MipOptions Linear

    Plain box filter on the stored values. What a linear, opaque, non-directional texture wants.

  • public static MipOptions Colour

    An sRGB colour texture.

  • public static MipOptions CutoutColour

    An sRGB colour texture with cut-out or unused alpha.

  • public static MipOptions NormalMap

    A tangent-space normal map.

Used by (3)

  • MipChainVixen.Core.Imaging
  • MipChainTestsVixen.Core.Imaging.Tests
  • TextureImporterVixen.Editor.Assets