diff options
Diffstat (limited to 'source/blender')
5 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 45b0d16b2e1..bd4f15dabab 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -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); } diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 4ff36816b7c..822d63d5786 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -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); diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 280ebcbb1aa..f079f2884e6 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -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]; diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl index 5bb9607d33c..9aab9ae7b4f 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl @@ -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); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index acccb9593bf..d7f3d914131 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -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); |