[Bf-blender-cvs] [e6705fad339] master: DRW: Add DRW_STATE_BLEND_PREMUL_UNDER

Clément Foucault noreply at git.blender.org
Wed May 1 12:10:55 CEST 2019


Commit: e6705fad3393867d2e3fea040f61931edf9d5709
Author: Clément Foucault
Date:   Wed May 1 10:48:13 2019 +0200
Branches: master
https://developer.blender.org/rBe6705fad3393867d2e3fea040f61931edf9d5709

DRW: Add DRW_STATE_BLEND_PREMUL_UNDER

Just basic alpha under operation with premultiplied source.

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

M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager_exec.c

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

diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index b0320a522f8..4d8fefbbc06 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -329,7 +329,7 @@ typedef enum {
   DRW_STATE_BLEND = (1 << 15),
   DRW_STATE_ADDITIVE = (1 << 16),
   DRW_STATE_MULTIPLY = (1 << 17),
-  /* DRW_STATE_TRANSMISSION  = (1 << 18), */ /* Not used */
+  DRW_STATE_BLEND_PREMUL_UNDER = (1 << 18),
   DRW_STATE_CLIP_PLANES = (1 << 19),
   /** Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */
   DRW_STATE_ADDITIVE_FULL = (1 << 20),
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 7e1fda14608..8e23a616ff5 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -205,7 +205,7 @@ void drw_state_set(DRWState state)
     int test;
     if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE |
                                   DRW_STATE_MULTIPLY | DRW_STATE_ADDITIVE_FULL |
-                                  DRW_STATE_BLEND_OIT,
+                                  DRW_STATE_BLEND_OIT | DRW_STATE_BLEND_PREMUL_UNDER,
                               test)) {
       if (test) {
         glEnable(GL_BLEND);
@@ -216,6 +216,9 @@ void drw_state_set(DRWState state)
                               GL_ONE,
                               GL_ONE_MINUS_SRC_ALPHA); /* Alpha */
         }
+        else if ((state & DRW_STATE_BLEND_PREMUL_UNDER) != 0) {
+          glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
+        }
         else if ((state & DRW_STATE_BLEND_PREMUL) != 0) {
           glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
         }



More information about the Bf-blender-cvs mailing list