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:
authorClément Foucault <foucault.clem@gmail.com>2018-11-15 20:13:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-15 20:16:30 +0300
commitc2164e579c3dde8c0fbb42e0c146bfd5ad1b563b (patch)
tree631fedacdf5e4830acf2a54c6ab7bc4225e48f04 /source/blender
parent11b3954346b1e4ee2d70d8f4efa2e1a57c9fbef8 (diff)
Eevee: Add irradiance smoothing
This is a parameter that will make the interpolation between irradiance cells of a same Irradiance Volume smoother, reducing the weight of the light leaking correction factors. It is usefull in some cases to avoid harsh lighting transition that can happen when a sample point it near a surface.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/scene.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c6
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c1
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c4
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h1
-rw-r--r--source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl1
-rw-r--r--source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl12
-rw-r--r--source/blender/makesdna/DNA_scene_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c6
9 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index ee30179e632..bd991d60681 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -872,6 +872,7 @@ void BKE_scene_init(Scene *sce)
sce->eevee.gi_visibility_resolution = 32;
sce->eevee.gi_cubemap_draw_size = 0.3f;
sce->eevee.gi_irradiance_draw_size = 0.1f;
+ sce->eevee.gi_irradiance_smoothing = 0.1f;
sce->eevee.taa_samples = 16;
sce->eevee.taa_render_samples = 64;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 1871aea86a4..afed64a0722 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2271,6 +2271,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_irradiance_smoothing")) {
+ for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
+ scene->eevee.gi_irradiance_smoothing = 0.1f;
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "Lamp", "float", "att_dist")) {
for (Lamp *la = bmain->lamp.first; la; la = la->id.next) {
la->att_dist = la->clipend;
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 36425e80094..873a63db355 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -671,6 +671,7 @@ static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lb
/* Disable all effects BUT high bitdepth shadows. */
scene_eval->eevee.flag &= SCE_EEVEE_SHADOW_HIGH_BITDEPTH;
scene_eval->eevee.taa_samples = 1;
+ scene_eval->eevee.gi_irradiance_smoothing = 0.0f;
stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__);
stl->g_data->background_alpha = 1.0f;
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 256425221f4..e4659306f5c 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -833,6 +833,8 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
EEVEE_StorageList *stl = vedata->stl;
LightCache *light_cache = stl->g_data->light_cache;
EEVEE_LightProbesInfo *pinfo = sldata->probes;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
eevee_lightprobes_extract_from_cache(sldata->probes, light_cache);
@@ -843,6 +845,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len - 1.0f;
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(scene_eval->eevee.gi_irradiance_smoothing);
sldata->common_data.prb_num_render_cube = max_ii(1, light_cache->cube_len);
sldata->common_data.prb_num_render_grid = max_ii(1, light_cache->grid_len);
sldata->common_data.prb_num_planar = pinfo->num_planar;
@@ -859,7 +862,6 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
if (!DRW_state_is_image_render() && !DRW_state_is_opengl_render() &&
(pinfo->do_grid_update || pinfo->do_cube_update))
{
- const DRWContextState *draw_ctx = DRW_context_state_get();
BLI_assert(draw_ctx->evil_C);
if (draw_ctx->scene->eevee.flag & SCE_EEVEE_GI_AUTOBAKE) {
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 7c431e6685c..09e444c40b2 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -653,6 +653,7 @@ typedef struct EEVEE_CommonUniformBuffer {
int prb_num_render_cube; /* int */
int prb_num_render_grid; /* int */
int prb_irradiance_vis_size; /* int */
+ float prb_irradiance_smooth; /* float */
float prb_lod_cube_max; /* float */
float prb_lod_planar_max; /* float */
/* Misc */
diff --git a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
index d26013ce132..9c5a212aead 100644
--- a/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/common_uniforms_lib.glsl
@@ -34,6 +34,7 @@ layout(std140) uniform common_block {
int prbNumRenderCube;
int prbNumRenderGrid;
int prbIrradianceVisSize;
+ float prbIrradianceSmooth;
float prbLodCubeMax;
float prbLodPlanarMax;
/* Misc*/
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
index e0cba826c76..a991e640a79 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
@@ -273,14 +273,18 @@ vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos)
float ws_dist_point_to_cell = length(ws_point_to_cell);
vec3 ws_light = ws_point_to_cell / ws_dist_point_to_cell;
- vec3 trilinear = mix(1 - trilinear_weight, trilinear_weight, offset);
- float weight = trilinear.x * trilinear.y * trilinear.z;
+ /* Smooth backface test */
+ float weight = saturate(dot(ws_light, N));
/* Precomputed visibility */
weight *= load_visibility_cell(cell, ws_light, ws_dist_point_to_cell, gd.g_vis_bias, gd.g_vis_bleed, gd.g_vis_range);
- /* Smooth backface test */
- weight *= dot(ws_light, N);
+ /* Smoother transition */
+ weight += prbIrradianceSmooth;
+
+ /* Trilinear weights */
+ vec3 trilinear = mix(1.0 - trilinear_weight, trilinear_weight, offset);
+ weight *= trilinear.x * trilinear.y * trilinear.z;
/* Avoid zero weight */
weight = max(0.00001, weight);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c78f622e8bc..3ad96f09555 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1460,6 +1460,8 @@ typedef struct SceneEEVEE {
int gi_diffuse_bounces;
int gi_cubemap_resolution;
int gi_visibility_resolution;
+ float gi_irradiance_smoothing;
+ float pad;
float gi_cubemap_draw_size;
float gi_irradiance_draw_size;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 123ed562343..850560646ec 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5682,6 +5682,12 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
"Size of the shadow map applied to each irradiance sample");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+ prop = RNA_def_property(srna, "gi_irradiance_smoothing", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_range(prop, 0.0f, FLT_MAX);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 5, 2);
+ RNA_def_property_float_default(prop, 0.1f);
+ RNA_def_property_ui_text(prop, "Irradiance Smoothing", "Smoother irradiance interpolation but introduce light bleeding");
+
prop = RNA_def_property(srna, "gi_show_irradiance", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_SHOW_IRRADIANCE);
RNA_def_property_boolean_default(prop, 0);