$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
light_probes.h File Reference
#include "sh_math.h"
#include "shader.h"
#include <cglm/cglm.h>
#include <pthread.h>
Include dependency graph for light_probes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SphereInstance_POD
 
struct  LightProbe
 
struct  LightProbeGrid
 

Enumerations

enum  { SH_TEXTURE_COUNT = 7 }
 Number of 3D textures used for packing SH coefficients (7 = 28 channels for 9 L2 coeffs) More...
 
enum  { TEXTURE_UNIT_SH_START = 8 }
 Starting texture unit for SH 3D textures. More...
 

Functions

void light_probe_grid_compute_aabb (LightProbeGrid *grid, const void *spheres, int count, size_t stride, float padding)
 Computes the AABB for the grid based on sphere instances. More...
 
void light_probe_grid_init_cpu (LightProbeGrid *grid, int dim_x, int dim_y, int dim_z)
 Initializes the grid structure (CPU only). More...
 
void light_probe_grid_init (LightProbeGrid *grid, int dim_x, int dim_y, int dim_z)
 Initializes the grid structure, creates SSBO, and starts worker thread. More...
 
void light_probe_grid_set_bounds (LightProbeGrid *grid, vec3 aabb_min, vec3 aabb_max)
 Sets the grid AABB and computes cell sizes from dimensions. More...
 
void light_probe_grid_set_scene (LightProbeGrid *grid, const void *spheres, int count, size_t stride)
 Updates the scene data used by the grid (copies it). More...
 
void light_probe_grid_update_async (LightProbeGrid *grid)
 Signals the worker thread to perform an SH update. More...
 
void light_probe_grid_sync (LightProbeGrid *grid)
 Checks if results are ready and uploads to GPU. Should be called on main thread. More...
 
void light_probe_render_debug (LightProbeGrid *grid, mat4 view, mat4 proj)
 Renders debug spheres for the probes. More...
 
void light_probe_grid_cleanup (LightProbeGrid *grid)
 Cleans up all resources (CPU, GPU, Threads). More...
 
void light_probe_grid_free_cpu (LightProbeGrid *grid)
 Cleans up CPU resources. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Number of 3D textures used for packing SH coefficients (7 = 28 channels for 9 L2 coeffs)

Enumerator
SH_TEXTURE_COUNT 

◆ anonymous enum

anonymous enum

Starting texture unit for SH 3D textures.

Enumerator
TEXTURE_UNIT_SH_START 

Function Documentation

◆ light_probe_grid_cleanup()

void light_probe_grid_cleanup ( LightProbeGrid grid)

Cleans up all resources (CPU, GPU, Threads).

Here is the call graph for this function:

◆ light_probe_grid_compute_aabb()

void light_probe_grid_compute_aabb ( LightProbeGrid grid,
const void *  spheres,
int  count,
size_t  stride,
float  padding 
)

Computes the AABB for the grid based on sphere instances.

Parameters
gridPointer to grid.
spheresArray of sphere instances (generic pointer to avoid GL dep in header if needed).
countNumber of spheres.
strideStride between spheres.
paddingPadding to add to the AABB.
Here is the call graph for this function:

◆ light_probe_grid_free_cpu()

void light_probe_grid_free_cpu ( LightProbeGrid grid)

Cleans up CPU resources.

◆ light_probe_grid_init()

void light_probe_grid_init ( LightProbeGrid grid,
int  dim_x,
int  dim_y,
int  dim_z 
)

Initializes the grid structure, creates SSBO, and starts worker thread.

Here is the call graph for this function:

◆ light_probe_grid_init_cpu()

void light_probe_grid_init_cpu ( LightProbeGrid grid,
int  dim_x,
int  dim_y,
int  dim_z 
)

Initializes the grid structure (CPU only).

Parameters
gridPointer to grid.
dim_xGrid dimension X.
dim_yGrid dimension Y.
dim_zGrid dimension Z.

◆ light_probe_grid_set_bounds()

void light_probe_grid_set_bounds ( LightProbeGrid grid,
vec3  aabb_min,
vec3  aabb_max 
)

Sets the grid AABB and computes cell sizes from dimensions.

◆ light_probe_grid_set_scene()

void light_probe_grid_set_scene ( LightProbeGrid grid,
const void *  spheres,
int  count,
size_t  stride 
)

Updates the scene data used by the grid (copies it).

Here is the call graph for this function:

◆ light_probe_grid_sync()

void light_probe_grid_sync ( LightProbeGrid grid)

Checks if results are ready and uploads to GPU. Should be called on main thread.

◆ light_probe_grid_update_async()

void light_probe_grid_update_async ( LightProbeGrid grid)

Signals the worker thread to perform an SH update.

◆ light_probe_render_debug()

void light_probe_render_debug ( LightProbeGrid grid,
mat4  view,
mat4  proj 
)

Renders debug spheres for the probes.

Parameters
gridPointer to grid.
viewView matrix.
projProjection matrix.
Here is the call graph for this function: