Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_lightprobes.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c61
1 files changed, 29 insertions, 32 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 4fbecfe3120..61ca2317572 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -37,6 +37,7 @@
#include "GPU_material.h"
#include "GPU_texture.h"
+#include "GPU_extensions.h"
#include "DEG_depsgraph_query.h"
@@ -171,32 +172,28 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
memset(stl->g_data->world_views, 0, sizeof(stl->g_data->world_views));
memset(stl->g_data->planar_views, 0, sizeof(stl->g_data->planar_views));
- /* Use fallback if we don't have gpu texture allocated an we cannot restore them. */
- bool use_fallback_lightcache = (scene_eval->eevee.light_cache == NULL) ||
- ((scene_eval->eevee.light_cache->grid_tx.tex == NULL) &&
- (scene_eval->eevee.light_cache->grid_tx.data == NULL)) ||
- ((scene_eval->eevee.light_cache->cube_tx.tex == NULL) &&
- (scene_eval->eevee.light_cache->cube_tx.data == NULL));
-
- if (use_fallback_lightcache && (sldata->fallback_lightcache == NULL)) {
+ if (EEVEE_lightcache_load(scene_eval->eevee.light_cache_data)) {
+ stl->g_data->light_cache = scene_eval->eevee.light_cache_data;
+ }
+ else {
+ if (!sldata->fallback_lightcache) {
#if defined(IRRADIANCE_SH_L2)
- int grid_res = 4;
+ int grid_res = 4;
#elif defined(IRRADIANCE_CUBEMAP)
- int grid_res = 8;
+ int grid_res = 8;
#elif defined(IRRADIANCE_HL2)
- int grid_res = 4;
+ int grid_res = 4;
#endif
- int cube_res = octahedral_size_from_cubesize(scene_eval->eevee.gi_cubemap_resolution);
- int vis_res = scene_eval->eevee.gi_visibility_resolution;
- sldata->fallback_lightcache = EEVEE_lightcache_create(
- 1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1});
+ sldata->fallback_lightcache = EEVEE_lightcache_create(
+ 1,
+ 1,
+ scene_eval->eevee.gi_cubemap_resolution,
+ scene_eval->eevee.gi_visibility_resolution,
+ (int[3]){grid_res, grid_res, 1});
+ }
+ stl->g_data->light_cache = sldata->fallback_lightcache;
}
- stl->g_data->light_cache = (use_fallback_lightcache) ? sldata->fallback_lightcache :
- scene_eval->eevee.light_cache;
-
- EEVEE_lightcache_load(stl->g_data->light_cache);
-
if (!sldata->probes) {
sldata->probes = MEM_callocN(sizeof(EEVEE_LightProbesInfo), "EEVEE_LightProbesInfo");
sldata->probe_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightProbe) * MAX_PROBE, NULL);
@@ -255,7 +252,7 @@ void EEVEE_lightbake_cache_init(EEVEE_ViewLayerData *sldata,
grp, "renderpass_block", EEVEE_material_default_render_pass_ubo_get(sldata));
struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
- DRW_shgroup_call(grp, geom, NULL);
+ DRW_shgroup_call_instances(grp, NULL, geom, 6);
}
{
@@ -508,8 +505,8 @@ void EEVEE_lightprobes_cache_add(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata
EEVEE_LightProbesInfo *pinfo = sldata->probes;
LightProbe *probe = (LightProbe *)ob->data;
- if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= MAX_PROBE) ||
- (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= MAX_PROBE) ||
+ if ((probe->type == LIGHTPROBE_TYPE_CUBE && pinfo->num_cube >= EEVEE_PROBE_MAX) ||
+ (probe->type == LIGHTPROBE_TYPE_GRID && pinfo->num_grid >= EEVEE_PROBE_MAX) ||
(probe->type == LIGHTPROBE_TYPE_PLANAR && pinfo->num_planar >= MAX_PLANAR)) {
printf("Too many probes in the view !!!\n");
return;
@@ -762,7 +759,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
/* For shading, save max level of the octahedron map */
- sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len - 1.0f;
+ sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len;
sldata->common_data.prb_lod_planar_max = (float)MAX_PLANAR_LOD_LEVEL;
sldata->common_data.prb_irradiance_vis_size = light_cache->vis_res;
sldata->common_data.prb_irradiance_smooth = square_f(scene_eval->eevee.gi_irradiance_smoothing);
@@ -785,15 +782,15 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
if (draw_ctx->scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) {
Scene *scene_orig = DEG_get_input_scene(draw_ctx->depsgraph);
- if (scene_orig->eevee.light_cache != NULL) {
+ if (scene_orig->eevee.light_cache_data != NULL) {
if (pinfo->do_grid_update) {
- scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_GRID;
+ scene_orig->eevee.light_cache_data->flag |= LIGHTCACHE_UPDATE_GRID;
}
- /* If we update grid we need to update the cube-maps too.
- * So always refresh cube-maps. */
- scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE;
- /* Tag the light-cache to auto update. */
- scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_AUTO;
+ /* If we update grid we need to update the cubemaps too.
+ * So always refresh cubemaps. */
+ scene_orig->eevee.light_cache_data->flag |= LIGHTCACHE_UPDATE_CUBE;
+ /* Tag the lightcache to auto update. */
+ scene_orig->eevee.light_cache_data->flag |= LIGHTCACHE_UPDATE_AUTO;
/* Use a notifier to trigger the operator after drawing. */
WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig);
}
@@ -1077,7 +1074,7 @@ void EEVEE_lightbake_filter_glossy(EEVEE_ViewLayerData *sldata,
pinfo->texel_size = 1.0f / (float)mipsize;
pinfo->padding_size = (i == maxlevel) ? 0 : (float)(1 << (maxlevel - i - 1));
pinfo->padding_size *= pinfo->texel_size;
- pinfo->layer = probe_idx;
+ pinfo->layer = probe_idx * 6;
pinfo->roughness = i / (float)maxlevel;
pinfo->roughness *= pinfo->roughness; /* Disney Roughness */
pinfo->roughness *= pinfo->roughness; /* Distribute Roughness accros lod more evenly */