1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-08 05:50:05 +00:00
12 Filter Flags
walbourn edited this page 2023-05-13 14:45:07 -07:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

DirectXTex
enum TEX_FILTER_FLAGS

TEX_FILTER_DEFAULT Default flags

Algorithm

This selects the filtering mode used for resizing and mipmap generation. In most cases it defaults to using "Fant" (aka "Box").

  • TEX_FILTER_POINT Nearest neighbhor
  • TEX_FILTER_LINEAR Bilinear/Trilinear interpolation
  • TEX_FILTER_CUBIC Bicubic/Tricubic interpoloation
  • TEX_FILTER_FANT Fant which is equivalent to a box filter for down-scaling.
  • TEX_FILTER_BOX Box filter (alias for Fant since they are equivalent for down-scaling). When using the non-WIC codepaths, Box filter fails if the texture is not a power of 2 in width & height.
  • TEX_FILTER_TRIANGLE Finite low-pass triangle filter. This is not supported by WIC so always uses custom filtering paths.

The legacy D3DX library implemented Point, Linear, Box, and Triangle.

Dithering

This selects the use of dithering for format conversions. By default it uses no dithering.

Wrap mode

This controls how edge pixels are filtered. It defaults to CLAMP which is the only one supported by the WIC code paths. These have no impact on POINT or BOX filtering methods.

  • TEX_FILTER_WRAP_U

  • TEX_FILTER_WRAP_V

  • TEX_FILTER_WRAP_W

  • TEX_FILTER_WRAP These indicates the texture will be used with wrap texture addressing modes D3D11_TEXTURE_ADDRESS_WRAP in U, V, and/or W. This affects Linear, Cubic, and Triangle filtering.

  • TEX_FILTER_MIRROR_U

  • TEX_FILTER_MIRROR_V

  • TEX_FILTER_MIRROR_W

  • TEX_FILTER_MIRROR These indicates the texture will be used with mirror texture addressing modes D3D11_TEXTURE_ADDRESS_MIRROR in U, V, and/or W. This affects Cubic filtering. For Linear and Triangle filtering, MIRROR and the default of clamp give the same result.

Color space

This controls color space transformation for conversions.

  • TEX_FILTER_SRGB_IN Indicates the input format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_FILTER_SRGB_OUT Indicates the output format is the sRGB format. This is implied if using a DXGI_FORMAT_*_SRGB format
  • TEX_FILTER_SRGB This is the same as setting both TEX_FILTER_SRGB_IN and TEX_FILTER_SRGB_OUT

The sRGB color space overall is approximately equivalent to gamma 2.2. It's actually linear below a threshold, and gamma 2.4 beyond that.

WIC usage

When both WIC-based and non-WIC based codepaths are in place, these flags can influence the standard logic choice. These are primarily used for testing and debugging purposes.

  • TEX_FILTER_FORCE_NON_WIC
  • TEX_FILTER_FORCE_WIC

TEX_FILTER_SEPARATE_ALPHA WIC makes use of pre-multiplied alpha when resizing images, which works fine for standard transparency data. If the alpha channel, however, contains some other kind of value then the resulting image can have 'holes' in it. Use of this flag uses an alternative algorithm which resizes the RGB and alpha channels independantly and then recombines the result. This flag is not used by the non-WIC code paths, but will cause the Convert() function to use non-WIC paths.

Convert channel selection

For Convert operations, these flags control special-case logic in the non-WIC paths. Without these flags, RGB to R conversions default to converting to a luminance value and RGB to RG conversion defaults to copying the RED and GREEN channels. These are implemented in the non-WIC code paths.

  • TEX_FILTER_RGB_COPY_RED When converting from RGB to R formats, this indicates that the RED channel could be copied. For RGB to RG conversions, it can be combined with GREEN or BLUE to control which channels end up in the output.
  • TEX_FILTER_RGB_COPY_GREEN When converting from RGB to R formats, this indicates that the GREEN channel could be copied. For RGB to RG conversions, it can be combined with RED or BLUE to control which channels end up in the output.
  • TEX_FILTER_RGB_COPY_BLUE When converting from RGB to R formats, this indicates that the BLUE channel could be copied. For RGB to RG conversions, it can be combined with RED or GREEN to control which channels end up in the output.
  • TEX_FILTER_RGB_COPY_ALPHA When converting from RGB(A) to R formats, this indicates that the ALPHA channel could be copied. For RGB(A) to RG conversions, it can be combined with RED or GREEN or BLUE to control which channels end up in the output.

Special conversion cases

For Convert operations, these flags enable special-case logic in the non-WIC paths.

  • TEX_FILTER_FLOAT_X2BIAS Enables special *2 -1 conversion cases for converting unorm <-> float, and positive-only-floats <-> float/snorm. These are typically used with normal maps.