Skip to content

GenerateMipMaps3D

Chuck Walbourn edited this page Jan 21, 2022 · 4 revisions
DirectXTex

Generates mipmaps for a 3D volume texture from a set of images representing the slices.

This generates mipmaps for 3D dimension textures (a.k.a. volume textures). For 1D and 2D dimension textures, see GenerateMipMaps.

HRESULT GenerateMipMaps3D( const Image* baseImages, size_t depth,
    TEX_FILTER_FLAGS filter, size_t levels,
    ScratchImage& mipChain );

HRESULT GenerateMipMaps3D( const Image* srcImages, size_t nimages,
    const TexMetadata& metadata,
    TEX_FILTER_FLAGS filter, size_t levels,
    ScratchImage& mipChain );

Parameters

baseImages/srcImages: The mipmap chain is created by repeatedly down-sizing the slices of base images. The first level of the resulting mipChain is set to a copy of the input baseImages.

depth: The Z dimension of the volume texture which is also the number of slices in the baseImages array.

filter: See Filter Flags. Note that for non-power-of-2 depth volume maps, only TEX_FILTER_TRIANGLE will give the expected results. It therefore defaults to Triangle for non-pow-of-2 volume maps, otherwise it defaults to Fant/Box.

levels: Number of mip map levels including base. A value of 0 indicates creating a full mipmap chain down to 1x1x1.

Example

ScratchImage baseImages;

...

ScratchImage mipChain;
hr = GenerateMipMaps3D( baseImages.GetImages(), baseImages.GetImageCount(),
    baseImages.GetMetadata(), TEX_FILTER_DEAFULT, 0, mipChain );
if ( FAILED(hr) )
    ...

Remarks

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.

Each miplevel of a 3D volume texture is half the size in width & height and half the number of slices of the one above to a minimum of 1.

This function does not make use of WIC for resizing since volume textures require 3D filtering methods.

Note: All slices in a miplevel must be in contiguous memory for working with Direct3D, which is how ScratchImage is implemented.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

For Development

  • 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

Related Projects

DirectXTex Rust bindings

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally