[Bf-blender-cvs] [494e4c0977a] blender2.8: Eevee: Fix Depth of Field.

Clément Foucault noreply at git.blender.org
Thu Jan 11 16:51:03 CET 2018


Commit: 494e4c0977aceadbe7add01eeacc5ad23f484957
Author: Clément Foucault
Date:   Thu Jan 11 15:11:59 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB494e4c0977aceadbe7add01eeacc5ad23f484957

Eevee: Fix Depth of Field.

It was using a wrong blending function.

===================================================================

M	source/blender/draw/engines/eevee/eevee_depth_of_field.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
index ef7e6412fc4..e700fb5058a 100644
--- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c
+++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c
@@ -213,7 +213,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
 		DRW_shgroup_uniform_vec3(grp, "dofParams", effects->dof_params, 1);
 		DRW_shgroup_call_add(grp, quad, NULL);
 
-		psl->dof_scatter = DRW_pass_create("DoF Scatter", DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE);
+		psl->dof_scatter = DRW_pass_create("DoF Scatter", DRW_STATE_WRITE_COLOR | DRW_STATE_ADDITIVE_FULL);
 
 		/* This create an empty batch of N triangles to be positioned
 		 * by the vertex shader 0.4ms against 6ms with instancing */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index a715e3b1742..fb736061c61 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -290,6 +290,7 @@ typedef enum {
 	DRW_STATE_MULTIPLY      = (1 << 16),
 	DRW_STATE_TRANSMISSION  = (1 << 17),
 	DRW_STATE_CLIP_PLANES   = (1 << 18),
+	DRW_STATE_ADDITIVE_FULL = (1 << 19), /* Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
 
 	DRW_STATE_WRITE_STENCIL    = (1 << 27),
 	DRW_STATE_STENCIL_EQUAL    = (1 << 28),
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 664c93a4fe4..c2318949e9c 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1545,7 +1545,8 @@ static void drw_state_set(DRWState state)
 	{
 		int test;
 		if (CHANGED_ANY_STORE_VAR(
-		        DRW_STATE_BLEND | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION,
+		        DRW_STATE_BLEND | DRW_STATE_ADDITIVE | DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION |
+		        DRW_STATE_ADDITIVE_FULL,
 		        test))
 		{
 			if (test) {
@@ -1566,6 +1567,10 @@ static void drw_state_set(DRWState state)
 					glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, /* RGB */
 					                    GL_ZERO, GL_ONE); /* Alpha */
 				}
+				else if ((state & DRW_STATE_ADDITIVE_FULL) != 0) {
+					/* Let alpha accumulate. */
+					glBlendFunc(GL_ONE, GL_ONE);
+				}
 				else {
 					BLI_assert(0);
 				}



More information about the Bf-blender-cvs mailing list