-
Notifications
You must be signed in to change notification settings - Fork 452
ScaleMipMapsAlphaForCoverage
DirectXTex |
---|
Scales mipmap alpha values to preserve alpha coverage based on an alpha test reference value.
This is intended for use after generating mipimaps with GenerateMipMaps. It does not support volume mipmaps.
HRESULT ScaleMipMapsAlphaForCoverage(
const Image* srcImages, size_t nimages, const TexMetadata& metadata, size_t item,
float alphaReference, ScratchImage& mipChain);
srcImages: The image array of miplevels to use as the image source which has nimages images. The first level of the resulting mipChain is set to a copy of the first image. Each level after that contains the same RGB data as the matching miplevel source image, but the alpha value is scaled.
metadata: Metadata describing the texture. The info.mipLevels
value should match the nimages
value passed to this function.
item: Is used when processing texture arrays to look up the right entry in mipChain
.
alphaReference: Is the alpha test reference value which ranges from 0 to 1.
mipChain: Is where the results are written. Generally it should be created to match the mipChain
returned by GenerateMipMaps and then this function is called once for each array item to set all the values.
ScratchImage baseImage;
...
ScratchImage mipChain;
hr = GenerateMipMaps( baseImage.GetImages(), baseImage.GetImageCount(),
baseImage.GetMetadata(), TEX_FILTER_DEFAULT, 0, mipChain );
if ( FAILED(hr) )
…
auto& info = mipChain.GetMetadata();
ScratchImage coverageMipChain;
hr = coverageMipChain.Initialize(info);
if (FAILED(hr))
…
for (size_t item = 0; item < info.arraySize; ++item)
{
auto img = mipChain.GetImage(0, item, 0);
assert(img);
hr = ScaleMipMapsAlphaForCoverage(img, info.mipLevels, info, item, 0.5f,
coverageMipChain);
if (FAILED(hr))
…
}
This function does not operate directly on block compressed images. See Decompress and Compress.
This function cannot operate directly on a planar format image. See ConvertToSinglePlane for a method for converting planar data to a format that is supported by this routine.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- Xbox Series X|S
- Windows Subsystem for Linux
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- GCC 10.5, 11.4, 12.3
- MinGW 12.2, 13.2
- CMake 3.20
DirectX Tool Kit for DirectX 11