$darkmode
#include <glad/glad.h>#include "light_probes.h"#include "log.h"#include "perf_timer.h"#include "profiler.h"#include "render_utils.h"#include "shader.h"#include "utils.h"#include <float.h>#include <math.h>#include <stdlib.h>#include <string.h>Data Structures | |
| struct | CachedSphere |
Macros | |
| #define | M_PI 3.14159265358979323846 |
| #define | USE_SH_BAKE_FACTORS 1 |
| #define | SH_COEFF_COUNT 9 |
| #define | GI_BOUNCE_SCALE 2.0F |
| #define | GI_MIN_DIST_RADII 1.05F |
| #define | GI_MAX_DIST_RADII 3.0F |
| #define | GI_EPSILON 0.000001F |
| #define | GI_HALF 0.5F |
| #define | GI_ZERO 0.0F |
Enumerations | |
| enum | { GI_DEBUG_PROBE_VERTICES = 6 , GI_WIRE_CUBE_VERTICES = 24 , GI_LOG_BUF_SIZE = 128 , GI_SMALL_LOG_BUF_SIZE = 64 } |
Functions | |
| static void | get_sphere_pos (const SphereInstance_POD *sphere, vec3 dest) |
| static float | get_sphere_radius (const SphereInstance_POD *sphere) |
| 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_free_cpu (LightProbeGrid *grid) |
| Cleans up CPU resources. More... | |
| static void | compute_probe_sh (const CachedSphere *cached_scene, int local_count, vec3 probe_pos, SH9 *sh_data) |
| static int | is_probe_inside_sphere (vec3 probe_pos, const CachedSphere *cached_scene, int local_count) |
| static void | light_probe_worker_compute_probe (LightProbeGrid *grid, int grid_x, int grid_y, int grid_z, const CachedSphere *cached_scene, int local_count) |
| static void * | precompute_cached_spheres (SphereInstance_POD *local_scene, int local_count) |
| static void * | light_probe_worker (void *arg) |
| 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_grid_cleanup (LightProbeGrid *grid) |
| Cleans up all resources (CPU, GPU, Threads). More... | |
| void | light_probe_render_debug (LightProbeGrid *grid, mat4 view, mat4 proj) |
| Renders debug spheres for the probes. More... | |
| #define GI_BOUNCE_SCALE 2.0F |
| #define GI_EPSILON 0.000001F |
| #define GI_HALF 0.5F |
| #define GI_MAX_DIST_RADII 3.0F |
| #define GI_MIN_DIST_RADII 1.05F |
| #define GI_ZERO 0.0F |
| #define M_PI 3.14159265358979323846 |
| #define SH_COEFF_COUNT 9 |
| #define USE_SH_BAKE_FACTORS 1 |
| anonymous enum |
|
static |
|
static |
|
static |
|
static |
| void light_probe_grid_cleanup | ( | LightProbeGrid * | grid | ) |
Cleans up all resources (CPU, GPU, Threads).
| 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.
| grid | Pointer to grid. |
| spheres | Array of sphere instances (generic pointer to avoid GL dep in header if needed). |
| count | Number of spheres. |
| stride | Stride between spheres. |
| padding | Padding to add to the AABB. |
| void light_probe_grid_free_cpu | ( | LightProbeGrid * | grid | ) |
Cleans up CPU resources.
| 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.
| void light_probe_grid_init_cpu | ( | LightProbeGrid * | grid, |
| int | dim_x, | ||
| int | dim_y, | ||
| int | dim_z | ||
| ) |
Initializes the grid structure (CPU only).
| grid | Pointer to grid. |
| dim_x | Grid dimension X. |
| dim_y | Grid dimension Y. |
| dim_z | Grid dimension Z. |
| void light_probe_grid_set_bounds | ( | LightProbeGrid * | grid, |
| vec3 | aabb_min, | ||
| vec3 | aabb_max | ||
| ) |
Sets the grid AABB and computes cell sizes from dimensions.
| 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).
| void light_probe_grid_sync | ( | LightProbeGrid * | grid | ) |
Checks if results are ready and uploads to GPU. Should be called on main thread.
| void light_probe_grid_update_async | ( | LightProbeGrid * | grid | ) |
Signals the worker thread to perform an SH update.
| void light_probe_render_debug | ( | LightProbeGrid * | grid, |
| mat4 | view, | ||
| mat4 | proj | ||
| ) |
Renders debug spheres for the probes.
| grid | Pointer to grid. |
| view | View matrix. |
| proj | Projection matrix. |
|
static |
|
static |
|
static |