Converts a height-map to a normal-map.

HRESULT ComputeNormalMap( _In_ const Image& srcImage, _In_ DWORD flags,
    _In_ float amplitude, _In_ DXGI_FORMAT format,
    _Out_ ScratchImage& normalMap );

HRESULT ComputeNormalMap( _In_reads_(nimages) const Image* srcImages,
    _In_ size_t nimages,
    _In_ const TexMetadata& metadata,
    _In_ DWORD flags, _In_ float amplitude, _In_ DXGI_FORMAT format,
    _Out_ ScratchImage& normalMaps );

Parameters

flags: a combination of the following flags
Selects which channel to use as the height. Luminance is a monochrome value computed from R, G, and B.
Selects mirroring semantics for scanline references. Otherwise defaults to wrap.
amplitude: Scaling factor for normals

format: Format of the resulting ScratchImage

Example

ScratchImage hmapImage;

...

ScratchImage normalMap;
hr = ComputeNormalMap( hmapImage.GetImage(0,0,0), CNMAP_CHANNEL_LUMINANCE | CNMAP_COMPUTE_OCCLUSION, 2.f, DXGI_FORMAT_R8G8B8A8_UNORM, normalMap );
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.

This method computes the normal by using the central difference with a kernel size of 3x3. The central differencing denominator used is 2.0. RGB channels in the destination contain biased (x,y,z) components of the normal.