Eevee : Add a setting for the number of indirect light bounce.

This is used to tweak the overall spread of the lighting. It is a per renderlayer setting.
This commit is contained in:
Clément Foucault 2017-10-01 02:19:10 +02:00
parent b03aa6afce
commit 3349f25502
6 changed files with 67 additions and 5 deletions

View File

@ -754,6 +754,24 @@ class RENDER_PT_eevee_antialiasing(RenderButtonsPanel, Panel):
col.prop(props, "taa_samples")
class RENDER_PT_eevee_global_illumination(RenderButtonsPanel, Panel):
bl_label = "Global Illumination"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
scene = context.scene
props = scene.layer_properties['BLENDER_EEVEE']
col = layout.column()
col.prop(props, "gi_diffuse_bounces")
classes = (
RENDER_MT_presets,
RENDER_MT_ffmpeg_presets,
@ -777,6 +795,7 @@ classes = (
RENDER_PT_eevee_postprocess_settings,
RENDER_PT_eevee_shadows,
RENDER_PT_eevee_antialiasing,
RENDER_PT_eevee_global_illumination,
)
if __name__ == "__main__": # only for live edit.

View File

@ -333,6 +333,26 @@ class RENDERLAYER_PT_eevee_antialiasing(RenderLayerButtonsPanel, Panel):
col.template_override_property(layer_props, scene_props, "taa_samples")
class RENDERLAYER_PT_eevee_global_illumination(RenderLayerButtonsPanel, Panel):
bl_label = "Global Illumination"
COMPAT_ENGINES = {'BLENDER_EEVEE'}
@classmethod
def poll(cls, context):
scene = context.scene
return scene and (scene.render.engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
scene = context.scene
scene_props = scene.layer_properties['BLENDER_EEVEE']
layer = bpy.context.render_layer
layer_props = layer.engine_overrides['BLENDER_EEVEE']
col = layout.column()
col.template_override_property(layer_props, scene_props, "gi_diffuse_bounces")
classes = (
RENDERLAYER_UL_renderlayers,
RENDERLAYER_PT_layers,
@ -345,6 +365,7 @@ classes = (
RENDERLAYER_PT_eevee_volumetric,
RENDERLAYER_PT_eevee_shadows,
RENDERLAYER_PT_eevee_antialiasing,
RENDERLAYER_PT_eevee_global_illumination,
)
if __name__ == "__main__": # only for live edit.

View File

@ -311,6 +311,8 @@ static void EEVEE_scene_layer_settings_create(RenderEngine *UNUSED(engine), IDPr
props->type == IDP_GROUP &&
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
BKE_collection_engine_property_add_int(props, "gi_diffuse_bounces", 3);
BKE_collection_engine_property_add_bool(props, "taa_enable", true);
BKE_collection_engine_property_add_int(props, "taa_samples", 8);

View File

@ -166,6 +166,10 @@ static void planar_pool_ensure_alloc(EEVEE_Data *vedata, int num_planar_ref)
void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(vedata))
{
const DRWContextState *draw_ctx = DRW_context_state_get();
SceneLayer *scene_layer = draw_ctx->scene_layer;
IDProperty *props = BKE_scene_layer_engine_evaluated_get(scene_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_EEVEE);
/* Shaders */
if (!e_data.probe_filter_glossy_sh) {
char *shader_str = NULL;
@ -276,6 +280,11 @@ void EEVEE_lightprobes_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *UNUSED(ved
sldata->planar_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR, NULL);
}
int prop_bounce_num = BKE_collection_engine_property_value_get_int(props, "gi_diffuse_bounces");
/* Update all probes if number of bounces mismatch. */
e_data.update_world = (sldata->probes->num_bounce != prop_bounce_num);
sldata->probes->num_bounce = prop_bounce_num;
/* Setup Render Target Cubemap */
/* We do this detach / attach dance to not generate an invalid framebuffer (mixed cubemap / 2D map) */
@ -340,7 +349,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *veda
float *col = ts.colorBackground;
if (wo) {
col = &wo->horr;
e_data.update_world = (wo->update_flag != 0);
e_data.update_world |= (wo->update_flag != 0);
wo->update_flag = 0;
if (wo->use_nodes && wo->nodetree) {
@ -1303,8 +1312,7 @@ void EEVEE_lightprobes_refresh(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
/* Reflection probes depend on diffuse lighting thus on irradiance grid,
* so update them first. */
const int max_bounce = 3;
while (pinfo->updated_bounce < max_bounce) {
while (pinfo->updated_bounce < pinfo->num_bounce) {
pinfo->num_render_grid = pinfo->num_grid;
for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
@ -1391,7 +1399,7 @@ skip_rendering:
}
#if 0
printf("Updated Grid %d : cell %d / %d, bounce %d / %d\n",
i, ped->updated_cells, ped->num_cell, pinfo->updated_bounce + 1, max_bounce);
i, ped->updated_cells, ped->num_cell, pinfo->updated_bounce + 1, pinfo->num_bounce);
#endif
/* Only do one probe per frame */
DRW_viewport_request_redraw();
@ -1405,7 +1413,7 @@ skip_rendering:
pinfo->updated_bounce++;
pinfo->num_render_grid = pinfo->num_grid;
if (pinfo->updated_bounce < max_bounce) {
if (pinfo->updated_bounce < pinfo->num_bounce) {
/* Retag all grids to update for next bounce */
for (int i = 1; (ob = pinfo->probes_grid_ref[i]) && (i < MAX_GRID); i++) {
EEVEE_LightProbeEngineData *ped = EEVEE_lightprobe_data_get(ob);

View File

@ -319,6 +319,7 @@ typedef struct EEVEE_LightProbesInfo {
int num_planar, cache_num_planar;
int update_flag;
int updated_bounce;
int num_bounce;
int grid_initialized;
/* Actual number of probes that have datas. */
int num_render_cube;

View File

@ -2574,6 +2574,7 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(shadow_high_bitdepth)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(taa_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(taa_samples)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(gi_diffuse_bounces)
/* object engine */
RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire)
@ -6180,6 +6181,16 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
/* see RNA_LAYER_ENGINE_GET_SET macro */
/* Indirect Lighting */
prop = RNA_def_property(srna, "gi_diffuse_bounces", PROP_INT, PROP_NONE);
RNA_def_property_int_funcs(prop, "rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_get",
"rna_LayerEngineSettings_Eevee_gi_diffuse_bounces_set", NULL);
RNA_def_property_ui_text(prop, "Bounces", "Number of time the light is reinjected inside light grids, "
"0 disable indirect diffuse light");
RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
/* Temporal Anti-Aliasing */
prop = RNA_def_property(srna, "taa_enable", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_taa_enable_get",