Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-07-24 16:33:28 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-07-24 20:24:50 +0300
commit68101fea687f12a7646230f509078452ccfccb2b (patch)
tree52c4017f8f3c3935356446196db05e075370ba6c /source/blender
parent8ac5b1fdb39010ba65c5da010f6ebcc71479a7ff (diff)
EEVEE-Next: Add back background opacity toggle
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_film.cc8
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_film.hh5
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_pipeline.cc1
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_shader_shared.hh4
-rw-r--r--source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl3
-rw-r--r--source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh1
6 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc
index ae84ea249b7..cdd753b988d 100644
--- a/source/blender/draw/engines/eevee_next/eevee_film.cc
+++ b/source/blender/draw/engines/eevee_next/eevee_film.cc
@@ -147,7 +147,8 @@ void Film::sync_mist()
inline bool operator==(const FilmData &a, const FilmData &b)
{
return (a.extent == b.extent) && (a.offset == b.offset) &&
- (a.filter_radius == b.filter_radius) && (a.scaling_factor == b.scaling_factor);
+ (a.filter_radius == b.filter_radius) && (a.scaling_factor == b.scaling_factor) &&
+ (a.background_opacity == b.background_opacity);
}
inline bool operator!=(const FilmData &a, const FilmData &b)
@@ -238,6 +239,11 @@ void Film::init(const int2 &extent, const rcti *output_rect)
* We need to figure out LOD bias first in order to preserve texture crispiness. */
data.scaling_factor = 1;
+ data.background_opacity = (scene.r.alphamode == R_ALPHAPREMUL) ? 0.0f : 1.0f;
+ if (inst_.is_viewport() && false /* TODO(fclem): StudioLight */) {
+ data.background_opacity = inst_.v3d->shading.studiolight_background;
+ }
+
FilmData &data_prev_ = data_;
if (assign_if_different(data_prev_, data)) {
sampling.reset();
diff --git a/source/blender/draw/engines/eevee_next/eevee_film.hh b/source/blender/draw/engines/eevee_next/eevee_film.hh
index 26e27c447bc..124fd79a1c0 100644
--- a/source/blender/draw/engines/eevee_next/eevee_film.hh
+++ b/source/blender/draw/engines/eevee_next/eevee_film.hh
@@ -89,6 +89,11 @@ class Film {
float2 pixel_jitter_get() const;
+ float background_opacity_get() const
+ {
+ return data_.background_opacity;
+ }
+
eViewLayerEEVEEPassType enabled_passes_get() const;
static bool pass_is_value(eViewLayerEEVEEPassType pass_type)
diff --git a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc
index 7b3cfbf5899..214fe9c7153 100644
--- a/source/blender/draw/engines/eevee_next/eevee_pipeline.cc
+++ b/source/blender/draw/engines/eevee_next/eevee_pipeline.cc
@@ -36,6 +36,7 @@ void WorldPipeline::sync(GPUMaterial *gpumat)
DRWShadingGroup *grp = DRW_shgroup_material_create(gpumat, world_ps_);
DRW_shgroup_uniform_texture(grp, "utility_tx", inst_.pipelines.utility_tx);
DRW_shgroup_call_obmat(grp, DRW_cache_fullscreen_quad_get(), camera_mat.ptr());
+ DRW_shgroup_uniform_float_copy(grp, "world_opacity_fade", inst_.film.background_opacity_get());
/* AOVs. */
DRW_shgroup_uniform_image_ref(grp, "aov_color_img", &rbufs.aov_color_tx);
DRW_shgroup_uniform_image_ref(grp, "aov_value_img", &rbufs.aov_value_tx);
diff --git a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
index d703f000ab6..3c10f633740 100644
--- a/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
+++ b/source/blender/draw/engines/eevee_next/eevee_shader_shared.hh
@@ -174,7 +174,9 @@ struct FilmData {
/** Is true if accumulation of filtered passes is needed. */
bool1 any_render_pass_1;
bool1 any_render_pass_2;
- float _pad0, _pad1;
+ /** Controlled by user in lookdev mode or by render settings. */
+ float background_opacity;
+ float _pad0;
/** Output counts per type. */
int color_len, value_len;
/** Index in color_accum_img or value_accum_img of each pass. -1 if pass is not enabled. */
diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl
index b32c3c1c4eb..ed75282a550 100644
--- a/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl
+++ b/source/blender/draw/engines/eevee_next/shaders/eevee_surf_world_frag.glsl
@@ -34,4 +34,7 @@ void main()
out_background.rgb = safe_color(g_emission) * (1.0 - g_holdout);
out_background.a = saturate(avg(g_transmittance)) * g_holdout;
+
+ /* World opacity. */
+ out_background = mix(vec4(0.0, 0.0, 0.0, 1.0), out_background, world_opacity_fade);
}
diff --git a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh
index 950164f5b86..2368061402c 100644
--- a/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh
+++ b/source/blender/draw/engines/eevee_next/shaders/infos/eevee_material_info.hh
@@ -140,6 +140,7 @@ GPU_SHADER_CREATE_INFO(eevee_surf_world)
.image_out(3, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_light_img")
.image_out(4, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_specular_color_img")
.image_out(5, Qualifier::READ_WRITE, GPU_RGBA16F, "rp_emission_img")
+ .push_constant(Type::FLOAT, "world_opacity_fade")
.fragment_out(0, Type::VEC4, "out_background")
.fragment_source("eevee_surf_world_frag.glsl")
.additional_info("eevee_aov_out"