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.
This commit is contained in:
parent
11b3954346
commit
c2164e579c
|
@ -446,6 +446,8 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
|
|||
col.prop(props, "gi_diffuse_bounces")
|
||||
col.prop(props, "gi_cubemap_resolution")
|
||||
col.prop(props, "gi_visibility_resolution", text="Diffuse Occlusion")
|
||||
col.prop(props, "gi_irradiance_smoothing")
|
||||
|
||||
|
||||
class RENDER_PT_eevee_indirect_lighting_display(RenderButtonsPanel, Panel):
|
||||
bl_label = "Display"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -34,6 +34,7 @@ layout(std140) uniform common_block {
|
|||
int prbNumRenderCube;
|
||||
int prbNumRenderGrid;
|
||||
int prbIrradianceVisSize;
|
||||
float prbIrradianceSmooth;
|
||||
float prbLodCubeMax;
|
||||
float prbLodPlanarMax;
|
||||
/* Misc*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue