MaterialX 1.39.2
Loading...
Searching...
No Matches
Harmonics.h File Reference

Spherical harmonics functionality. More...

Go to the source code of this file.

Classes

class  ShCoeffs< C, B >
 Class template for a vector of spherical harmonic coefficients. More...
 

Typedefs

using Sh3ScalarCoeffs = ShCoeffs<double, 3>
 Double-precision scalar coefficients for third-order spherical harmonics.
 
using Sh3ColorCoeffs = ShCoeffs<Color3d, 3>
 Double-precision color coefficients for third-order spherical harmonics.
 

Functions

MX_RENDER_API Sh3ColorCoeffs projectEnvironment (ConstImagePtr env, bool irradiance=false)
 Project an environment map to third-order SH, with an optional convolution to convert radiance to irradiance.
 
MX_RENDER_API ImagePtr normalizeEnvironment (ConstImagePtr env, float envRadiance, float maxTexelRadiance)
 Normalize an environment to the given radiance.
 
MX_RENDER_API void computeDominantLight (ConstImagePtr env, Vector3 &lightDir, Color3 &lightColor)
 Compute the dominant light direction and color of an environment map.
 
MX_RENDER_API ImagePtr renderEnvironment (const Sh3ColorCoeffs &shEnv, unsigned int width, unsigned int height)
 Render the given spherical harmonic signal to an environment map.
 
MX_RENDER_API ImagePtr renderReferenceIrradiance (ConstImagePtr env, unsigned int width, unsigned int height)
 Render a reference irradiance map from the given environment map, using brute-force computations for a slow but accurate result.
 

Detailed Description

Spherical harmonics functionality.

Function Documentation

◆ computeDominantLight()

MX_RENDER_API void computeDominantLight ( ConstImagePtr env,
Vector3 & lightDir,
Color3 & lightColor )

Compute the dominant light direction and color of an environment map.

Parameters
envAn environment map in lat-long format.
lightDirReturns the dominant light direction of the environment.
lightColorReturns the color of the light from the dominant direction.

◆ normalizeEnvironment()

MX_RENDER_API ImagePtr normalizeEnvironment ( ConstImagePtr env,
float envRadiance,
float maxTexelRadiance )

Normalize an environment to the given radiance.

Parameters
envAn environment map in lat-long format.
envRadianceThe radiance to which the environment map should be normalized.
maxTexelRadianceThe maximum radiance allowed for any individual texel of the map.
Returns
A new normalized environment map, in the same format as the original.

◆ projectEnvironment()

MX_RENDER_API Sh3ColorCoeffs projectEnvironment ( ConstImagePtr env,
bool irradiance = false )

Project an environment map to third-order SH, with an optional convolution to convert radiance to irradiance.

Parameters
envAn environment map in lat-long format.
irradianceIf true, then the returned signal will be convolved by a clamped cosine kernel to generate irradiance.
Returns
The projection of the environment to third-order SH.

◆ renderEnvironment()

MX_RENDER_API ImagePtr renderEnvironment ( const Sh3ColorCoeffs & shEnv,
unsigned int width,
unsigned int height )

Render the given spherical harmonic signal to an environment map.

Parameters
shEnvThe color signal of the environment encoded as third-order SH.
widthThe width of the output environment map.
heightThe height of the output environment map.
Returns
An environment map in the lat-long format.

◆ renderReferenceIrradiance()

MX_RENDER_API ImagePtr renderReferenceIrradiance ( ConstImagePtr env,
unsigned int width,
unsigned int height )

Render a reference irradiance map from the given environment map, using brute-force computations for a slow but accurate result.

Parameters
envAn environment map in lat-long format.
widthThe width of the output irradiance map.
heightThe height of the output irradiance map.
Returns
An irradiance map in the lat-long format.