-
Notifications
You must be signed in to change notification settings - Fork 464
ComputeNormalMap
| DirectXTex |
|---|
Converts a height-map to a normal-map.
HRESULT ComputeNormalMap(
const Image& srcImage, CNMAP_FLAGS flags,
float amplitude, DXGI_FORMAT format,
ScratchImage& normalMap );
HRESULT ComputeNormalMap(
const Image* srcImages, size_t nimages,
const TexMetadata& metadata,
CNMAP_FLAGS flags, float amplitude, DXGI_FORMAT format,
ScratchImage& normalMaps );flags: a combination of the following flags
-
CNMAP_DEFAULTDefault flags
Selects which channel to use as the height. Luminance is a monochrome value computed from R, G, and B using classic scaling (R*0.2125 + G*0.7154 + B*0.0721).
CNMAP_CHANNEL_REDCNMAP_CHANNEL_GREENCNMAP_CHANNEL_BLUECNMAP_CHANNEL_ALPHACNMAP_CHANNEL_LUMINANCE
Selects mirroring semantics for scanline references. Otherwise defaults to wrap.
-
CNMAP_MIRROR_U -
CNMAP_MIRROR_V -
CNMAP_MIRRORSame as bothCNMAP_MIRROR_UandCNMAP_MIRROR_V -
CNMAP_INVERT_SIGNInverts the sign of the computed normal vector -
CNMAP_COMPUTE_OCCLUSIONComputes a crude occlusion term and stores in the resulting alpha channel
amplitude: Scaling factor for normals
format: Format of the resulting ScratchImage
These functions will succeed with an S_OK or will return an HRESULT error code (E_INVALIDARG, E_OUTOFMEMORY, E_FAIL, E_POINTER, E_UNEXPECTED, HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), or HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)).
These functions are marked noexcept, and do not throw C++ exceptions.
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.
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) )
...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 - v20
- GCC 10.5, 11.4, 12.3, 13.3, 14.2
- MinGW 12.2, 13.2
- CMake 3.21
DirectX Tool Kit for DirectX 11