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.
This commit is contained in:
@@ -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. */
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user