SHMath
This is an implementation of the original D3DXMath library spherical harmonics math functions using DirectXMath.
See this blog post for more information and details.
API
All functions are in the C++ namespace DirectX
XMSHEvalDirection
Evaluates the Spherical Harmonic basis functions. Equivalent to D3DXSHEvalDirection function.
XMSHRotate
Rotates SH vector by a rotation matrix. Equivalent to the D3DXSHRotate function.
XMSHRotateZ
Rotates the SH vector in the Z axis by an angle. Equivalent to the D3DXSHRotateZ function.
XMSHAdd
Adds two SH vectors. Equivalent to the D3DXSHAdd function.
XMSHScale
Scales a SH vector. Equivalent to the D3DXSHScale function.
XMSHDot
Computes the dot product of two SH vectors. Equivalent to the D3DXSHDot function.
XMSHMultiply, XMSHMultiply2/3/4/5/6
Computes the product of two functions represented using SH. Equivalent to D3DXSHMultiply2, D3DXSHMultiply3, D3DXSHMultiply4, D3DXSHMultiply5, and D3DXSHMultiply6.
XMSHEvalDirectionalLight
Evaluates a directional light and returns spectral SH data. Equivalent to the D3DXSHEvalDirectionalLight function.
XMSHEvalSphericalLight
Evaluates a spherical light and returns spectral SH data. Equivalent to the D3DXEvalSphericalLight function.
XMSHEvalConeLight
Evaluates a light that is a cone of constant intensity and returns spectral SH data. Equivalent to the D3DXSHEvalConeLight function.
XMSHEvalHemisphereLight
Evaluates a light that is a linear interpolant between two colors over the sphere. Equivalent to the D3DXSHEvalHemisphereLight function.
SHProjectCubeMap
Projects a function represented in a cube map into spherical harmonics. Equivalent to the D3DX11SHProjectCubeMap function.
For DirectX 11, you must do
#include <d3d11.h>before#include <DirectXSH.h>.
For DirectX 12, you must do
#include <d3d12.h>before#include <DirectXSH.h>.