Eevee: Bloom: Add Clamp setting

It's purpose is to limit the amount of light that spread across the screen.

Not entierly sure if it's very usefull, but it sure help to avoid to drown the screen in bloom.
This commit is contained in:
Clément Foucault 2017-08-19 02:39:16 +02:00
parent 2abc21ace5
commit 63f70ef14d
7 changed files with 21 additions and 1 deletions

View File

@ -680,6 +680,7 @@ class RENDER_PT_eevee_postprocess_settings(RenderButtonsPanel, Panel):
col.prop(props, "bloom_knee")
col.prop(props, "bloom_radius")
col.prop(props, "bloom_intensity")
col.prop(props, "bloom_clamp")
class RENDER_PT_eevee_volumetric(RenderButtonsPanel, Panel):

View File

@ -215,6 +215,7 @@ class RENDERLAYER_PT_eevee_postprocess_settings(RenderLayerButtonsPanel, Panel):
col.template_override_property(layer_props, scene_props, "bloom_knee")
col.template_override_property(layer_props, scene_props, "bloom_radius")
col.template_override_property(layer_props, scene_props, "bloom_intensity")
col.template_override_property(layer_props, scene_props, "bloom_clamp")
class RENDERLAYER_PT_eevee_volumetric(RenderLayerButtonsPanel, Panel):

View File

@ -367,6 +367,7 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
float knee = BKE_collection_engine_property_value_get_float(props, "bloom_knee");
float intensity = BKE_collection_engine_property_value_get_float(props, "bloom_intensity");
float radius = BKE_collection_engine_property_value_get_float(props, "bloom_radius");
effects->bloom_clamp = BKE_collection_engine_property_value_get_float(props, "bloom_clamp");
/* determine the iteration count */
const float minDim = (float)MIN2(blitsize[0], blitsize[1]);
@ -1047,6 +1048,7 @@ void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
eevee_create_bloom_pass("Bloom Upsample", effects, e_data.bloom_upsample_sh[use_highres], &psl->bloom_upsample, true);
grp = eevee_create_bloom_pass("Bloom Blit", effects, e_data.bloom_blit_sh[use_antiflicker], &psl->bloom_blit, false);
DRW_shgroup_uniform_vec4(grp, "curveThreshold", effects->bloom_curve_threshold, 1);
DRW_shgroup_uniform_float(grp, "clampIntensity", &effects->bloom_clamp, 1);
grp = eevee_create_bloom_pass("Bloom Resolve", effects, e_data.bloom_resolve_sh[use_highres], &psl->bloom_resolve, true);
DRW_shgroup_uniform_float(grp, "bloomIntensity", &effects->bloom_intensity, 1);
}

View File

@ -302,6 +302,7 @@ static void EEVEE_scene_layer_settings_create(RenderEngine *UNUSED(engine), IDPr
BKE_collection_engine_property_add_float(props, "bloom_knee", 0.5f);
BKE_collection_engine_property_add_float(props, "bloom_intensity", 0.8f);
BKE_collection_engine_property_add_float(props, "bloom_radius", 6.5f);
BKE_collection_engine_property_add_float(props, "bloom_clamp", 1.0f);
BKE_collection_engine_property_add_bool(props, "motion_blur_enable", false);
BKE_collection_engine_property_add_int(props, "motion_blur_samples", 8);

View File

@ -370,6 +370,7 @@ typedef struct EEVEE_EffectsInfo {
float blit_texel_size[2];
float downsamp_texel_size[MAX_BLOOM_STEP][2];
float bloom_intensity;
float bloom_clamp;
float bloom_sample_scale;
float bloom_curve_threshold[4];
float unf_source_texel_size[2];

View File

@ -31,6 +31,7 @@ uniform vec2 sourceBufferTexelSize;
/* Step Blit */
uniform vec4 curveThreshold;
uniform float clampIntensity;
/* Step Upsample */
uniform sampler2D baseBuffer; /* Previous accumulation buffer */
@ -161,7 +162,11 @@ vec4 step_blit(void)
rq = curveThreshold.z * rq * rq;
/* Combine and apply the brightness response curve. */
m *= max(rq, br - curveThreshold.w) / max(br, 1e-5);
m *= max(rq, br - curveThreshold.w) / max(1e-5, br);
/* Clamp pixel intensity */
br = max(1e-5, brightness(m));
m *= 1.0 - max(0.0, br - clampIntensity) / br;
return vec4(m, 1.0);
}

View File

@ -6477,6 +6477,15 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
prop = RNA_def_property(srna, "bloom_clamp", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_clamp_get",
"rna_LayerEngineSettings_Eevee_bloom_clamp_set", NULL);
RNA_def_property_ui_text(prop, "Clamp", "Maximum intensity a bloom pixel can have");
RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
prop = RNA_def_property(srna, "bloom_intensity", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_intensity_get",
"rna_LayerEngineSettings_Eevee_bloom_intensity_set", NULL);