Blender  V3.3
Classes | Macros | Typedefs | Functions
eevee_lightcache.c File Reference
#include "DRW_render.h"
#include "BKE_global.h"
#include "BLI_endian_switch.h"
#include "BLI_threads.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "BKE_object.h"
#include "DNA_collection_types.h"
#include "DNA_lightprobe_types.h"
#include "PIL_time.h"
#include "eevee_lightcache.h"
#include "eevee_private.h"
#include "GPU_capabilities.h"
#include "GPU_context.h"
#include "WM_api.h"
#include "WM_types.h"
#include "BLO_read_write.h"
#include "wm_window.h"

Go to the source code of this file.

Classes

struct  EEVEE_LightBake
 

Macros

#define IRRADIANCE_SAMPLE_SIZE_X   4 /* 3 in reality */
 
#define IRRADIANCE_SAMPLE_SIZE_Y   2
 
#define IRRADIANCE_FORMAT   GPU_RGBA8
 
#define IRRADIANCE_MAX_POOL_LAYER   256
 
#define IRRADIANCE_MAX_POOL_SIZE   1024
 
#define MAX_IRRADIANCE_SAMPLES
 

Typedefs

typedef struct EEVEE_LightBake EEVEE_LightBake
 

Functions

void DRW_opengl_context_enable (void)
 
void DRW_opengl_context_disable (void)
 
void DRW_opengl_render_context_enable (void *re_gl_context)
 
void DRW_opengl_render_context_disable (void *re_gl_context)
 
void DRW_gpu_render_context_enable (void *re_gpu_context)
 
void DRW_gpu_render_context_disable (void *re_gpu_context)
 
Light Cache
static uint eevee_lightcache_memsize_get (LightCache *lcache)
 
static bool eevee_lightcache_version_check (const LightCache *lcache)
 
static bool eevee_lightcache_can_be_saved (LightCache *lcache)
 
static int eevee_lightcache_irradiance_sample_count (LightCache *lcache)
 
void EEVEE_lightcache_info_update (SceneEEVEE *eevee)
 
static void irradiance_pool_size_get (int visibility_size, int total_samples, int r_size[3])
 
static bool EEVEE_lightcache_validate (const LightCache *light_cache, const int cube_len, const int cube_res, const int grid_len, const int irr_size[3])
 
LightCacheEEVEE_lightcache_create (const int grid_len, const int cube_len, const int cube_size, const int vis_size, const int irr_size[3])
 
static bool eevee_lightcache_static_load (LightCache *lcache)
 
bool EEVEE_lightcache_load (LightCache *lcache)
 
static void eevee_lightbake_readback_irradiance (LightCache *lcache)
 
static void eevee_lightbake_readback_reflections (LightCache *lcache)
 
void EEVEE_lightcache_free (LightCache *lcache)
 
static void write_lightcache_texture (BlendWriter *writer, LightCacheTexture *tex)
 
void EEVEE_lightcache_blend_write (BlendWriter *writer, LightCache *cache)
 
static void direct_link_lightcache_texture (BlendDataReader *reader, LightCacheTexture *lctex)
 
void EEVEE_lightcache_blend_read_data (BlendDataReader *reader, LightCache *cache)
 
Light Bake Context
static void eevee_lightbake_context_enable (EEVEE_LightBake *lbake)
 
static void eevee_lightbake_context_disable (EEVEE_LightBake *lbake)
 

Light Bake Job

#define SORT_PROBE(elems_type, prbs, elems, elems_len, comp_fn)
 
static void eevee_lightbake_count_probes (EEVEE_LightBake *lbake)
 
static void eevee_lightbake_create_render_target (EEVEE_LightBake *lbake, int rt_res)
 
static void eevee_lightbake_create_resources (EEVEE_LightBake *lbake)
 
wmJobEEVEE_lightbake_job_create (struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, int delay, int frame)
 
voidEEVEE_lightbake_job_data_alloc (struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job, int frame)
 
void EEVEE_lightbake_job_data_free (void *custom_data)
 
static void eevee_lightbake_delete_resources (EEVEE_LightBake *lbake)
 
static void eevee_lightbake_cache_create (EEVEE_Data *vedata, EEVEE_LightBake *lbake)
 
static void eevee_lightbake_copy_irradiance (EEVEE_LightBake *lbake, LightCache *lcache)
 
static void eevee_lightbake_render_world_sample (void *ved, void *user_data)
 
static void cell_id_to_grid_loc (EEVEE_LightGrid *egrid, int cell_idx, int r_local_cell[3])
 
static void compute_cell_id (EEVEE_LightGrid *egrid, LightProbe *probe, int cell_idx, int *r_final_idx, int r_local_cell[3], int *r_stride)
 
static void grid_loc_to_world_loc (EEVEE_LightGrid *egrid, const int local_cell[3], float r_pos[3])
 
static void eevee_lightbake_render_grid_sample (void *ved, void *user_data)
 
static void eevee_lightbake_render_probe_sample (void *ved, void *user_data)
 
static float eevee_lightbake_grid_influence_volume (EEVEE_LightGrid *grid)
 
static float eevee_lightbake_cube_influence_volume (EEVEE_LightProbe *eprb)
 
static bool eevee_lightbake_grid_comp (EEVEE_LightGrid *grid_a, EEVEE_LightGrid *grid_b)
 
static bool eevee_lightbake_cube_comp (EEVEE_LightProbe *prb_a, EEVEE_LightProbe *prb_b)
 
static void eevee_lightbake_gather_probes (EEVEE_LightBake *lbake)
 
void EEVEE_lightbake_update (void *custom_data)
 
static bool lightbake_do_sample (EEVEE_LightBake *lbake, void(*render_callback)(void *ved, void *user_data))
 
void EEVEE_lightbake_job (void *custom_data, short *stop, short *do_update, float *progress)
 
void EEVEE_lightbake_update_world_quick (EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, const Scene *scene)
 

Detailed Description

Eevee's indirect lighting cache.

Definition in file eevee_lightcache.c.

Macro Definition Documentation

◆ IRRADIANCE_FORMAT

#define IRRADIANCE_FORMAT   GPU_RGBA8

Definition at line 53 of file eevee_lightcache.c.

◆ IRRADIANCE_MAX_POOL_LAYER

#define IRRADIANCE_MAX_POOL_LAYER   256

Definition at line 57 of file eevee_lightcache.c.

◆ IRRADIANCE_MAX_POOL_SIZE

#define IRRADIANCE_MAX_POOL_SIZE   1024

Definition at line 58 of file eevee_lightcache.c.

◆ IRRADIANCE_SAMPLE_SIZE_X

#define IRRADIANCE_SAMPLE_SIZE_X   4 /* 3 in reality */

Definition at line 45 of file eevee_lightcache.c.

◆ IRRADIANCE_SAMPLE_SIZE_Y

#define IRRADIANCE_SAMPLE_SIZE_Y   2

Definition at line 46 of file eevee_lightcache.c.

◆ MAX_IRRADIANCE_SAMPLES

#define MAX_IRRADIANCE_SAMPLES
Value:

Definition at line 59 of file eevee_lightcache.c.

◆ SORT_PROBE

#define SORT_PROBE (   elems_type,
  prbs,
  elems,
  elems_len,
  comp_fn 
)
Value:
{ \
bool sorted = false; \
while (!sorted) { \
sorted = true; \
for (int i = 0; i < (elems_len)-1; i++) { \
if ((comp_fn)((elems) + i, (elems) + i + 1)) { \
SWAP(elems_type, (elems)[i], (elems)[i + 1]); \
SWAP(LightProbe *, (prbs)[i], (prbs)[i + 1]); \
sorted = false; \
} \
} \
} \
} \
((void)0)
SyclQueue void void size_t num_bytes void

Definition at line 1253 of file eevee_lightcache.c.

Typedef Documentation

◆ EEVEE_LightBake

Function Documentation

◆ cell_id_to_grid_loc()

static void cell_id_to_grid_loc ( EEVEE_LightGrid egrid,
int  cell_idx,
int  r_local_cell[3] 
)
static

Definition at line 1041 of file eevee_lightcache.c.

References LightGridCache::resolution.

Referenced by compute_cell_id().

◆ compute_cell_id()

static void compute_cell_id ( EEVEE_LightGrid egrid,
LightProbe probe,
int  cell_idx,
int *  r_final_idx,
int  r_local_cell[3],
int *  r_stride 
)
static

◆ direct_link_lightcache_texture()

static void direct_link_lightcache_texture ( BlendDataReader reader,
LightCacheTexture lctex 
)
static

◆ DRW_gpu_render_context_disable()

void DRW_gpu_render_context_disable ( void re_gpu_context)

◆ DRW_gpu_render_context_enable()

void DRW_gpu_render_context_enable ( void re_gpu_context)

◆ DRW_opengl_context_disable()

void DRW_opengl_context_disable ( void  )

◆ DRW_opengl_context_enable()

void DRW_opengl_context_enable ( void  )

◆ DRW_opengl_render_context_disable()

void DRW_opengl_render_context_disable ( void re_gl_context)

◆ DRW_opengl_render_context_enable()

void DRW_opengl_render_context_enable ( void re_gl_context)

◆ eevee_lightbake_cache_create()

static void eevee_lightbake_cache_create ( EEVEE_Data vedata,
EEVEE_LightBake lbake 
)
static

Definition at line 892 of file eevee_lightcache.c.

References EEVEE_PrivateData::background_alpha, EEVEE_LightProbeVisTest::cached, EEVEE_LightProbeVisTest::collection, EEVEE_TextureList::color, DEG_get_evaluated_scene(), EEVEE_LightBake::depsgraph, DRW_curves_update(), DRW_render_instance_buffer_finish(), DRW_render_object_iter(), DRW_render_viewport_size_set(), DRW_view_create(), DRW_view_default_get(), DRW_view_default_set(), DRW_view_set_active(), Scene::eevee, EEVEE_effects_cache_init(), EEVEE_effects_draw_init(), EEVEE_effects_init(), EEVEE_lightbake_cache_init(), EEVEE_lightprobes_cache_finish(), EEVEE_lightprobes_cache_init(), EEVEE_lightprobes_init(), EEVEE_lights_cache_finish(), EEVEE_lights_cache_init(), EEVEE_materials_cache_finish(), EEVEE_materials_cache_init(), EEVEE_materials_init(), EEVEE_render_cache(), EEVEE_shadows_init(), EEVEE_shadows_update(), EEVEE_subsurface_cache_init(), EEVEE_subsurface_draw_init(), EEVEE_view_layer_data_ensure(), EEVEE_volumes_cache_finish(), EEVEE_volumes_cache_init(), EEVEE_volumes_draw_init(), EFFECT_VOLUMETRIC, EEVEE_StorageList::effects, EEVEE_EffectsInfo::enabled_effects, EEVEE_Data::fbl, LightProbe::flag, SceneEEVEE::flag, EEVEE_StorageList::g_data, SceneEEVEE::gi_irradiance_smoothing, GPU_texture_height(), GPU_texture_width(), EEVEE_LightProbeVisTest::invert, LIGHTPROBE_FLAG_INVERT_GROUP, MEM_callocN, negate_v3(), NULL, EEVEE_LightBake::probe, EEVEE_ViewLayerData::probes, EEVEE_PrivateData::render_timesteps, EEVEE_LightBake::rt_color, EEVEE_LightBake::rt_depth, SCE_EEVEE_SHADOW_HIGH_BITDEPTH, EEVEE_LightBake::sldata, EEVEE_Data::stl, SceneEEVEE::taa_samples, EEVEE_Data::txl, unit_m4(), view, EEVEE_LightProbesInfo::vis_data, and LightProbe::visibility_grp.

Referenced by eevee_lightbake_render_grid_sample(), eevee_lightbake_render_probe_sample(), and eevee_lightbake_render_world_sample().

◆ eevee_lightbake_context_disable()

static void eevee_lightbake_context_disable ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_context_enable()

static void eevee_lightbake_context_enable ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_copy_irradiance()

static void eevee_lightbake_copy_irradiance ( EEVEE_LightBake lbake,
LightCache lcache 
)
static

◆ eevee_lightbake_count_probes()

static void eevee_lightbake_count_probes ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_create_render_target()

static void eevee_lightbake_create_render_target ( EEVEE_LightBake lbake,
int  rt_res 
)
static

◆ eevee_lightbake_create_resources()

static void eevee_lightbake_create_resources ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_cube_comp()

static bool eevee_lightbake_cube_comp ( EEVEE_LightProbe prb_a,
EEVEE_LightProbe prb_b 
)
static

◆ eevee_lightbake_cube_influence_volume()

static float eevee_lightbake_cube_influence_volume ( EEVEE_LightProbe eprb)
static

Definition at line 1234 of file eevee_lightcache.c.

References LightProbeCache::attenuationmat, and mat4_to_scale().

Referenced by eevee_lightbake_cube_comp().

◆ eevee_lightbake_delete_resources()

static void eevee_lightbake_delete_resources ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_gather_probes()

static void eevee_lightbake_gather_probes ( EEVEE_LightBake lbake)
static

◆ eevee_lightbake_grid_comp()

static bool eevee_lightbake_grid_comp ( EEVEE_LightGrid grid_a,
EEVEE_LightGrid grid_b 
)
static

◆ eevee_lightbake_grid_influence_volume()

static float eevee_lightbake_grid_influence_volume ( EEVEE_LightGrid grid)
static

Definition at line 1229 of file eevee_lightcache.c.

References LightGridCache::mat, and mat4_to_scale().

Referenced by eevee_lightbake_grid_comp().

◆ EEVEE_lightbake_job()

void EEVEE_lightbake_job ( void custom_data,
short *  stop,
short *  do_update,
float progress 
)

Definition at line 1359 of file eevee_lightcache.c.

References BLI_assert, BLI_thread_is_main(), EEVEE_LightBake::bounce_curr, EEVEE_LightBake::bounce_len, EEVEE_LightBake::cube, LightCache::cube_data, EEVEE_LightBake::cube_len, EEVEE_LightBake::cube_offset, EEVEE_LightBake::cube_prb, DEG_evaluate_on_framechange(), DEG_get_evaluated_view_layer(), DEG_graph_relations_update(), EEVEE_LightBake::delay, depsgraph, EEVEE_LightBake::depsgraph, EEVEE_LightBake::do_update, eevee_lightbake_context_disable(), eevee_lightbake_context_enable(), eevee_lightbake_count_probes(), eevee_lightbake_create_render_target(), eevee_lightbake_create_resources(), eevee_lightbake_delete_resources(), eevee_lightbake_gather_probes(), eevee_lightbake_readback_irradiance(), eevee_lightbake_readback_reflections(), eevee_lightbake_render_grid_sample(), eevee_lightbake_render_probe_sample(), eevee_lightbake_render_world_sample(), EEVEE_lightbake_update(), LightCache::flag, EEVEE_LightBake::frame, G, EEVEE_LightBake::gl_context, EEVEE_LightBake::grid, EEVEE_LightBake::grid_curr, LightCache::grid_data, EEVEE_LightBake::grid_len, EEVEE_LightBake::grid_prb, LightProbe::grid_resolution_x, LightProbe::grid_resolution_y, LightProbe::grid_resolution_z, EEVEE_LightBake::grid_sample, EEVEE_LightBake::grid_sample_len, EEVEE_LightBake::lcache, lightbake_do_sample(), LIGHTCACHE_BAKED, LIGHTCACHE_BAKING, LIGHTCACHE_INVALID, LIGHTCACHE_UPDATE_CUBE, LIGHTCACHE_UPDATE_GRID, LIGHTCACHE_UPDATE_WORLD, NULL, PIL_sleep_ms(), EEVEE_LightBake::probe, EEVEE_LightBake::progress, EEVEE_LightBake::rt_res, EEVEE_LightBake::stop, and EEVEE_LightBake::view_layer.

Referenced by EEVEE_lightbake_job_create(), and light_cache_bake_exec().

◆ EEVEE_lightbake_job_create()

wmJob* EEVEE_lightbake_job_create ( struct wmWindowManager wm,
struct wmWindow win,
struct Main bmain,
struct ViewLayer view_layer,
struct Scene scene,
int  delay,
int  frame 
)

◆ EEVEE_lightbake_job_data_alloc()

void* EEVEE_lightbake_job_data_alloc ( struct Main bmain,
struct ViewLayer view_layer,
struct Scene scene,
bool  run_as_job,
int  frame 
)

◆ EEVEE_lightbake_job_data_free()

void EEVEE_lightbake_job_data_free ( void custom_data)

◆ eevee_lightbake_readback_irradiance()

static void eevee_lightbake_readback_irradiance ( LightCache lcache)
static

◆ eevee_lightbake_readback_reflections()

static void eevee_lightbake_readback_reflections ( LightCache lcache)
static

◆ eevee_lightbake_render_grid_sample()

static void eevee_lightbake_render_grid_sample ( void ved,
void user_data 
)
static

Definition at line 1099 of file eevee_lightcache.c.

References EEVEE_LightBake::bounce_curr, EEVEE_LightBake::bounce_len, LightProbe::clipend, LightProbe::clipsta, EEVEE_ViewLayerData::common_data, EEVEE_ViewLayerData::common_ubo, compute_cell_id(), DEG_get_evaluated_scene(), EEVEE_LightBake::depsgraph, Scene::eevee, eevee_lightbake_cache_create(), eevee_lightbake_copy_irradiance(), EEVEE_lightbake_filter_diffuse(), EEVEE_lightbake_filter_visibility(), EEVEE_lightbake_render_scene(), EEVEE_RAY_DIFFUSE, EEVEE_view_layer_data_ensure(), LightCache::flag, float(), GPU_uniformbuf_update(), EEVEE_LightBake::grid, EEVEE_LightBake::grid_curr, EEVEE_LightBake::grid_len, grid_loc_to_world_loc(), EEVEE_LightBake::grid_prev, EEVEE_LightBake::grid_sample, EEVEE_LightBake::grid_sample_len, LightCache::grid_tx, LightProbe::intensity, LightGridCache::level_bias, SceneEEVEE::light_cache_data, LIGHTCACHE_UPDATE_GRID, LightGridCache::offset, pos, EEVEE_CommonUniformBuffer::prb_num_planar, EEVEE_CommonUniformBuffer::prb_num_render_cube, EEVEE_CommonUniformBuffer::prb_num_render_grid, EEVEE_LightBake::probe, EEVEE_CommonUniformBuffer::ray_depth, EEVEE_CommonUniformBuffer::ray_type, EEVEE_LightBake::rt_color, EEVEE_LightBake::rt_depth, EEVEE_LightBake::rt_fb, EEVEE_CommonUniformBuffer::spec_toggle, EEVEE_CommonUniformBuffer::sss_toggle, EEVEE_LightBake::store_fb, stride, SWAP, LightCacheTexture::tex, EEVEE_LightBake::total_irr_samples, user_data, LightProbe::vis_blur, EEVEE_LightBake::vis_res, and LightGridCache::visibility_range.

Referenced by EEVEE_lightbake_job().

◆ eevee_lightbake_render_probe_sample()

static void eevee_lightbake_render_probe_sample ( void ved,
void user_data 
)
static

◆ eevee_lightbake_render_world_sample()

static void eevee_lightbake_render_world_sample ( void ved,
void user_data 
)
static

◆ EEVEE_lightbake_update()

void EEVEE_lightbake_update ( void custom_data)

◆ EEVEE_lightbake_update_world_quick()

void EEVEE_lightbake_update_world_quick ( struct EEVEE_ViewLayerData sldata,
struct EEVEE_Data vedata,
const Scene scene 
)

◆ EEVEE_lightcache_blend_read_data()

void EEVEE_lightcache_blend_read_data ( BlendDataReader reader,
LightCache cache 
)

◆ EEVEE_lightcache_blend_write()

void EEVEE_lightcache_blend_write ( BlendWriter writer,
LightCache cache 
)

◆ eevee_lightcache_can_be_saved()

static bool eevee_lightcache_can_be_saved ( LightCache lcache)
static

◆ EEVEE_lightcache_create()

LightCache* EEVEE_lightcache_create ( int  grid_len,
int  cube_len,
int  cube_size,
int  vis_size,
const int  irr_size[3] 
)

◆ EEVEE_lightcache_free()

void EEVEE_lightcache_free ( LightCache lcache)

◆ EEVEE_lightcache_info_update()

void EEVEE_lightcache_info_update ( SceneEEVEE eevee)

◆ eevee_lightcache_irradiance_sample_count()

static int eevee_lightcache_irradiance_sample_count ( LightCache lcache)
static

◆ EEVEE_lightcache_load()

bool EEVEE_lightcache_load ( LightCache lcache)

◆ eevee_lightcache_memsize_get()

static uint eevee_lightcache_memsize_get ( LightCache lcache)
static

◆ eevee_lightcache_static_load()

static bool eevee_lightcache_static_load ( LightCache lcache)
static

◆ EEVEE_lightcache_validate()

static bool EEVEE_lightcache_validate ( const LightCache light_cache,
const int  cube_len,
const int  cube_res,
const int  grid_len,
const int  irr_size[3] 
)
static

◆ eevee_lightcache_version_check()

static bool eevee_lightcache_version_check ( const LightCache lcache)
static

◆ grid_loc_to_world_loc()

static void grid_loc_to_world_loc ( EEVEE_LightGrid egrid,
const int  local_cell[3],
float  r_pos[3] 
)
static

◆ irradiance_pool_size_get()

static void irradiance_pool_size_get ( int  visibility_size,
int  total_samples,
int  r_size[3] 
)
static

◆ lightbake_do_sample()

static bool lightbake_do_sample ( EEVEE_LightBake lbake,
void(*)(void *ved, void *user_data render_callback 
)
static

◆ write_lightcache_texture()

static void write_lightcache_texture ( BlendWriter writer,
LightCacheTexture tex 
)
static