diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-03-13 00:02:20 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-03-13 00:02:39 +0300 |
commit | 41cb5658803bf3b96f18e93c74c6af66ecdb1e83 (patch) | |
tree | 077ec7abca4fa7ca1377fcd4d6d051fc0e714e17 /source | |
parent | f16bdf1075b04ced7918d6f367e66d2f39f56724 (diff) |
Fix T60902 Eevee: Environment texture partially visible on transp. render
This was due to environement not being rendered with alpha blending. So
color was still written and contributed to the final render color. Now
we multiply by background alpha so that it removes any background pixels
intensity.
For this reason this made the (incorrect) final premult unecessary.
Diffstat (limited to 'source')
7 files changed, 13 insertions, 14 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 1f46fee7398..4baeff7ab5e 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -314,7 +314,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat const float *col = G_draw.block.colorBackground; /* LookDev */ - EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, wo, pinfo); + EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, 1.0f, wo, pinfo); /* END */ if (!grp && wo) { col = &wo->horr; @@ -328,7 +328,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat switch (status) { case GPU_MAT_SUCCESS: grp = DRW_shgroup_material_create(gpumat, psl->probe_background); - DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); + DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f); /* TODO (fclem): remove those (need to clean the GLSL files). */ DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo); @@ -349,7 +349,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat if (grp == NULL) { grp = DRW_shgroup_create(EEVEE_shaders_probe_default_sh_get(), psl->probe_background); DRW_shgroup_uniform_vec3(grp, "color", col, 1); - DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); + DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f); DRW_shgroup_call_add(grp, geom, NULL); } } @@ -892,6 +892,8 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us GPU_framebuffer_bind(fbl->planarref_fb); GPU_framebuffer_clear_depth(fbl->planarref_fb, 1.0); + vedata->stl->g_data->background_alpha = 1.0f; + /* Slight modification: we handle refraction as normal * shading and don't do SSRefraction. */ diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index d954ff3b0e2..2f89476e832 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -52,6 +52,7 @@ static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata) void EEVEE_lookdev_cache_init( EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass, + float background_alpha, World *UNUSED(world), EEVEE_LightProbesInfo *pinfo) { EEVEE_StorageList *stl = vedata->stl; @@ -114,7 +115,7 @@ void EEVEE_lookdev_cache_init( *grp = DRW_shgroup_create(shader, pass); axis_angle_to_mat3_single(stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z); DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix); - DRW_shgroup_uniform_float(*grp, "backgroundAlpha", &stl->g_data->background_alpha, 1); + DRW_shgroup_uniform_float_copy(*grp, "backgroundAlpha", background_alpha); DRW_shgroup_uniform_vec3(*grp, "color", background_color, 1); DRW_shgroup_call_add(*grp, geom, NULL); if (!pinfo) { diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 2744b719cea..4e6d5ce386a 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -967,7 +967,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const float *col = G_draw.block.colorBackground; /* LookDev */ - EEVEE_lookdev_cache_init(vedata, &grp, psl->background_pass, wo, NULL); + EEVEE_lookdev_cache_init(vedata, &grp, psl->background_pass, stl->g_data->background_alpha, wo, NULL); /* END */ if (!grp && wo) { diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 07485167fe3..8656db8e075 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -1001,7 +1001,9 @@ void EEVEE_render_draw(EEVEE_Data *vedata, struct RenderEngine *engine, struct R void EEVEE_render_update_passes(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer); /** eevee_lookdev.c */ -void EEVEE_lookdev_cache_init(EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass, struct World *world, EEVEE_LightProbesInfo *pinfo); +void EEVEE_lookdev_cache_init( + EEVEE_Data *vedata, DRWShadingGroup **grp, DRWPass *pass, float background_alpha, + struct World *world, EEVEE_LightProbesInfo *pinfo); void EEVEE_lookdev_draw_background(EEVEE_Data *vedata); /** eevee_engine.c */ diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 0cf1d31f8b8..82cca4f653c 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -210,12 +210,6 @@ static void eevee_render_result_combined( vedata->stl->g_data->overscan_pixels + rect->ymin, BLI_rcti_size_x(rect), BLI_rcti_size_y(rect), 4, 0, rp->rect); - - /* Premult alpha */ - int pixels_len = BLI_rcti_size_x(rect) * BLI_rcti_size_y(rect); - for (int i = 0; i < pixels_len * 4; i += 4) { - mul_v3_fl(rp->rect + i, rp->rect[i + 3]); - } } static void eevee_render_result_subsurface( diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl index 126f2d9610a..7c00c9f3b73 100644 --- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl @@ -58,5 +58,5 @@ void main() { background_color = color; #endif - FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), backgroundAlpha); + FragColor = vec4(clamp(background_color, vec3(0.0), vec3(1e10)), 1.0) * backgroundAlpha; } diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 6c645cb9d22..df1a0b9e2a8 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -3070,7 +3070,7 @@ uniform float backgroundAlpha; void node_output_world(Closure surface, Closure volume, out Closure result) { #ifndef VOLUMETRICS - result.radiance = surface.radiance; + result.radiance = surface.radiance * backgroundAlpha; result.opacity = backgroundAlpha; #else result = volume; |