diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-07-01 15:43:44 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-07-01 15:44:01 +0300 |
commit | 7a4c99de5a637c87c03151cd671b347590140c17 (patch) | |
tree | 2ada1fd7037c501183faa3951f733c897996f157 | |
parent | 809f81cc3a821cb708b918e84e856cb6ae765e38 (diff) |
Fix T66292: Alpha Blend transparency glitches with volume
4 files changed, 9 insertions, 10 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 166e8ac7473..152b8fa5d0a 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -653,11 +653,11 @@ typedef struct EEVEE_CommonUniformBuffer { float ao_offset, ao_bounce_fac, ao_quality, ao_settings; /* vec4 */ /* Volumetric */ /* -- 16 byte aligned -- */ - int vol_tex_size[3], pad3; /* ivec3 */ - float vol_depth_param[3], pad4; /* vec3 */ - float vol_inv_tex_size[3], pad5; /* vec3 */ - float vol_jitter[3], pad6; /* vec3 */ - float vol_coord_scale[2], pad7[2]; /* vec2 */ + int vol_tex_size[3], pad3; /* ivec3 */ + float vol_depth_param[3], pad4; /* vec3 */ + float vol_inv_tex_size[3], pad5; /* vec3 */ + float vol_jitter[3], pad6; /* vec3 */ + float vol_coord_scale[4]; /* vec4 */ /* -- 16 byte aligned -- */ float vol_history_alpha; /* float */ float vol_light_clamp; /* float */ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 9c8ec6e52a4..f85c30044a9 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -178,6 +178,8 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) common_data->vol_coord_scale[0] = viewport_size[0] / (float)(tile_size * tex_size[0]); common_data->vol_coord_scale[1] = viewport_size[1] / (float)(tile_size * tex_size[1]); + common_data->vol_coord_scale[2] = 1.0f / viewport_size[0]; + common_data->vol_coord_scale[3] = 1.0f / viewport_size[1]; /* TODO compute snap to maxZBuffer for clustered rendering */ if ((common_data->vol_tex_size[0] != tex_size[0]) || diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index 3a31afc0224..274269846bc 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -915,8 +915,7 @@ void main() # endif # if defined(USE_ALPHA_BLEND) - /* XXX fragile, better use real viewport resolution */ - vec2 uvs = gl_FragCoord.xy / vec2(2 * textureSize(maxzBuffer, 0).xy); + vec2 uvs = gl_FragCoord.xy * volCoordScale.zw; vec3 transmittance, scattering; volumetric_resolve(uvs, gl_FragCoord.z, transmittance, scattering); fragColor.rgb = cl.radiance * transmittance + scattering; diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl index 757eb59eaa1..1ff7e848c40 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_resolve_frag.glsl @@ -2,9 +2,7 @@ /* Based on Frosbite Unified Volumetric. * https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite */ -/* Step 4 : Apply final integration on top of the scene color. - * Note that we do the blending ourself instead of relying - * on hardware blending which would require 2 pass. */ +/* Step 4 : Apply final integration on top of the scene color. */ uniform sampler2D inSceneDepth; |