$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
sh_math.h
Go to the documentation of this file.
1 #ifndef SH_MATH_H
2 #define SH_MATH_H
3 
4 #include <cglm/cglm.h>
5 
6 /* Ramamoorthi 9 Coefficients for Irradiance Environment Maps */
7 /* L00, L1-1, L10, L11, L2-2, L2-1, L20, L21, L22 */
8 /* We use vec4 to align to std430 (16 bytes per coefficient) */
9 /* The 4th component is padding (or unused) */
10 typedef struct {
11  vec4 coeffs[9];
12 } SH9;
13 
17 void sh_zero(SH9* sh_ptr);
18 
25 void sh_project_directional(const vec3 dir, const vec3 color, SH9* out_sh);
26 
33 void sh_eval_irradiance(const vec3 normal, const SH9* sh_ptr, vec3 out_color);
34 
35 #endif /* SH_MATH_H */
void sh_eval_irradiance(const vec3 normal, const SH9 *sh_ptr, vec3 out_color)
Evaluates the irradiance from SH coefficients in a given direction.
Definition: sh_math.c:81
void sh_project_directional(const vec3 dir, const vec3 color, SH9 *out_sh)
Projects a directional light into SH coefficients.
Definition: sh_math.c:41
void sh_zero(SH9 *sh_ptr)
Initialize SH coefficients to zero.
Definition: sh_math.c:32
Definition: sh_math.h:10