Math v0.2.0
SIMD optimized C++ mathematics library
Loading...
Searching...
No Matches
sh.hpp File Reference

Common spherical harmonics functions. More...

#include "math/ibl.hpp"
#include "math/matrix.hpp"

Macros

#define M_SQRT_PI   1.77245385090551602729816748334114518
#define M_SQRT3   1.73205080756887729352744634150587237
#define M_SQRT5   2.23606797749978969640917366873127624
#define M_SQRT15   3.87298334620741688517926539978239961

Variables

constexpr math::int32 sh2Count = 4
constexpr math::int32 sh3Count = 9
constexpr math::int32 sh4Count = 16
constexpr float ki3 [sh3Count]
 Precomputed Lambertian reflection coefficients for the 3 band spherical harmonics.

Detailed Description

Common spherical harmonics functions.

Spherical harmonics (SH) are used to represent functions on the surface of a sphere, particularly for lighting and shading. SH allows for efficient approximations of complex lighting environments, such as image-based lighting (IBL), by encoding diffuse light and low-frequency details. SH are commonly used in precomputed radiance transfer (PRT) to achieve realistic lighting with low computational cost, especially for dynamic and global illumination in 3D scenes, enabling real-time performance in games.

Based on this project: https://google.github.io/filament/Filament.html

Variable Documentation

◆ sh2Count

math::int32 sh2Count = 4
constexpr

L1 spherical harmonics coefficient count. (2 * 2)

◆ sh3Count

math::int32 sh3Count = 9
constexpr

L2 spherical harmonics coefficient count. (3 * 3)

◆ sh4Count

math::int32 sh4Count = 16
constexpr

L3 spherical harmonics coefficient count. (4 * 4)

◆ ki3

float ki3[sh3Count]
constexpr
Initial value:
=
{
(float)0.886226925452757940959713778283912688,
(float)1.023326707946488278722085851768497380,
(float)1.023326707946488278722085851768497380,
(float)1.023326707946488278722085851768497380,
(float)0.143014255134963907956091588857816532,
(float)0.286028510269927815912183177715633065,
(float)0.495415912200751318295033343019895256,
(float)0.286028510269927815912183177715633065,
(float)0.143014255134963907956091588857816532
}

Precomputed Lambertian reflection coefficients for the 3 band spherical harmonics.