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>2019-05-01 12:01:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-01 13:09:18 +0300
commitb581f1929287381fe9c2761dc514d5bfa7cbe41c (patch)
tree73700c8103bf22c25f8805d2ccd0e1c50ec28655 /source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl
parent47717060af0944560ebed11e6995c8536ff689c7 (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/effect_dof_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_dof_frag.glsl9
1 files changed, 7 insertions, 2 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
}