1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-22 04:20:07 +00:00

Created ComputeNormalMap (markdown)

Chuck Walbourn 2015-06-21 23:07:38 -07:00
parent ffe476928b
commit 608f04f7dc

53
ComputeNormalMap.md Normal file

@ -0,0 +1,53 @@
Converts a height-map to a normal-map.
HRESULT ComputeNormalMap( const Image& srcImage, DWORD flags,
float amplitude, DXGI_FORMAT format,
ScratchImage& normalMap );
HRESULT ComputeNormalMap( const Image* srcImages, size_t nimages,
const TexMetadata& metadata,
DWORD flags, float amplitude, DXGI_FORMAT format,
ScratchImage& normalMaps );
# Parameters
_flags_: a combination of the following flags
* ``CNMAP_DEFAULT`` Default flags
Selects which channel to use as the height. Luminance is the average of R, G, and B.
* ``CNMAP_CHANNEL_RED``
* ``CNMAP_CHANNEL_GREEN``
* ``CNMAP_CHANNEL_BLUE``
* ``CNMAP_CHANNEL_ALPHA``
* ``CNMAP_CHANNEL_LUMINANCE``
Selects mirroring semantics for scanline references. Otherwise defaults to wrap.
* ``CNMAP_MIRROR_U``
* ``CNMAP_MIRROR_V``
* ``CNMAP_MIRROR`` Same as both ``CNMAP_MIRROR_U`` and ``CNMAP_MIRROR_V``
* ``CNMAP_INVERT_SIGN`` Inverts the sign of the computed normal vector
* ``CNMAP_COMPUTE_OCCLUSION`` Computes a crude occlusion term and stores in the resulting alpha channel
_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.