Eevee: Bloom: Add Bloom Color

Moar artistic control yay!
This commit is contained in:
Clément Foucault 2017-08-19 02:40:02 +02:00
parent 63f70ef14d
commit 5720890cf8
7 changed files with 24 additions and 5 deletions

View File

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

View File

@ -214,6 +214,7 @@ class RENDERLAYER_PT_eevee_postprocess_settings(RenderLayerButtonsPanel, Panel):
col.template_override_property(layer_props, scene_props, "bloom_threshold")
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_color")
col.template_override_property(layer_props, scene_props, "bloom_intensity")
col.template_override_property(layer_props, scene_props, "bloom_clamp")

View File

@ -366,6 +366,7 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
float threshold = BKE_collection_engine_property_value_get_float(props, "bloom_threshold");
float knee = BKE_collection_engine_property_value_get_float(props, "bloom_knee");
float intensity = BKE_collection_engine_property_value_get_float(props, "bloom_intensity");
const float *color = BKE_collection_engine_property_value_get_float_array(props, "bloom_color");
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");
@ -381,7 +382,8 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
effects->bloom_curve_threshold[1] = knee * 2.0f;
effects->bloom_curve_threshold[2] = 0.25f / max_ff(1e-5f, knee);
effects->bloom_curve_threshold[3] = threshold;
effects->bloom_intensity = intensity;
mul_v3_v3fl(effects->bloom_color, color, intensity);
/* Downsample buffers */
copy_v2_v2_int(texsize, blitsize);
@ -1050,7 +1052,7 @@ void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
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);
DRW_shgroup_uniform_vec3(grp, "bloomColor", effects->bloom_color, 1);
}
{

View File

@ -297,7 +297,9 @@ static void EEVEE_scene_layer_settings_create(RenderEngine *UNUSED(engine), IDPr
BKE_collection_engine_property_add_float(props, "bokeh_max_size", 100.0f);
BKE_collection_engine_property_add_float(props, "bokeh_threshold", 1.0f);
float default_bloom_color[3] = {1.0f, 1.0f, 1.0f};
BKE_collection_engine_property_add_bool(props, "bloom_enable", false);
BKE_collection_engine_property_add_float_array(props, "bloom_color", default_bloom_color, 3);
BKE_collection_engine_property_add_float(props, "bloom_threshold", 0.8f);
BKE_collection_engine_property_add_float(props, "bloom_knee", 0.5f);
BKE_collection_engine_property_add_float(props, "bloom_intensity", 0.8f);

View File

@ -369,7 +369,7 @@ typedef struct EEVEE_EffectsInfo {
float source_texel_size[2];
float blit_texel_size[2];
float downsamp_texel_size[MAX_BLOOM_STEP][2];
float bloom_intensity;
float bloom_color[3];
float bloom_clamp;
float bloom_sample_scale;
float bloom_curve_threshold[4];

View File

@ -39,7 +39,7 @@ uniform vec2 baseBufferTexelSize;
uniform float sampleScale;
/* Step Resolve */
uniform float bloomIntensity;
uniform vec3 bloomColor;
in vec4 uvcoordsvar;
@ -200,7 +200,7 @@ vec4 step_resolve(void)
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
#endif
vec4 base = textureLod(baseBuffer, uvcoordsvar.xy, 0.0);
vec3 cout = base.rgb + blur * bloomIntensity;
vec3 cout = base.rgb + blur * bloomColor;
return vec4(cout, base.a);
}

View File

@ -2563,6 +2563,9 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(float, Eevee, COLLECTION_MODE_NONE, _NAME_)
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Eevee, COLLECTION_MODE_NONE, _NAME_, _LEN_)
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Eevee, COLLECTION_MODE_NONE, _NAME_)
@ -2628,8 +2631,10 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_max_size)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bokeh_threshold)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(bloom_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_threshold)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT_ARRAY(bloom_color, 3)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_knee)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_radius)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_clamp)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(bloom_intensity)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(motion_blur_enable)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(motion_blur_samples)
@ -6460,6 +6465,14 @@ 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_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_color_get",
"rna_LayerEngineSettings_Eevee_bloom_color_set", NULL);
RNA_def_property_ui_text(prop, "Color", "Color applied to the bloom effect");
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_knee", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Eevee_bloom_knee_get",
"rna_LayerEngineSettings_Eevee_bloom_knee_set", NULL);