diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-01 12:01:01 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-01 13:09:18 +0300 |
commit | b581f1929287381fe9c2761dc514d5bfa7cbe41c (patch) | |
tree | 73700c8103bf22c25f8805d2ccd0e1c50ec28655 /source/blender/draw/engines/eevee/shaders | |
parent | 47717060af0944560ebed11e6995c8536ff689c7 (diff) |
Eevee: Add support for alpha background in viewport
Viewport now displays alpha checkerboard pattern like Cycles does when
film alpha is set to "Transparent".
Some small workarounds were necessary for Depth of Field and correct TAA
support.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl | 9 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl index 8a10962c6ef..d8cec17af58 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl @@ -5,6 +5,7 @@ uniform sampler2D colorBuffer; uniform sampler2D depthBuffer; uniform vec2 dofParams; +uniform bool unpremult; #define dof_mul dofParams.x /* distance * aperturesize * invsensorsize */ #define dof_bias dofParams.y /* aperturesize * invsensorsize */ @@ -241,8 +242,12 @@ void main(void) fragColor = (far_col + near_col + focus_col) * inv_weight_sum; # ifdef USE_ALPHA_DOF - /* Unpremult */ - fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0; + /* Sigh... viewport expect premult output but + * the final render output needs to be with + * associated alpha. */ + if (unpremult) { + fragColor.rgb /= (fragColor.a > 0.0) ? fragColor.a : 1.0; + } # endif } diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl index 518eff29c62..ac6751fb5fb 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl @@ -39,7 +39,6 @@ vec3 clip_to_aabb(vec3 color, vec3 minimum, vec3 maximum, vec3 average) void main() { ivec2 texel = ivec2(gl_FragCoord.xy); - float depth = texelFetch(depthBuffer, texel, 0).r; vec2 motion = texelFetch(velocityBuffer, texel, 0).rg; /* Decode from unsigned normalized 16bit texture. */ @@ -96,6 +95,9 @@ void main() color_history = (out_of_view) ? color : color_history; FragColor = safe_color(color_history); + /* There is some ghost issue if we use the alpha + * in the viewport. Overwritting alpha fixes it. */ + FragColor.a = color.a; } #else |