[Bf-blender-cvs] [1fff3e02c2d] blender2.8: DRW: Add DRW_STATE_BLEND_PREMUL blend mode.
Clément Foucault
noreply at git.blender.org
Wed May 2 20:54:29 CEST 2018
Commit: 1fff3e02c2d76488e92ca0ccba76c318a56fde37
Author: Clément Foucault
Date: Mon Apr 23 22:58:47 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1fff3e02c2d76488e92ca0ccba76c318a56fde37
DRW: Add DRW_STATE_BLEND_PREMUL blend mode.
===================================================================
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 a9c14762a04..31046377b19 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -268,6 +268,7 @@ typedef enum {
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_BLEND_PREMUL = (1 << 20), /* Use that if color is already premult by alpha. */
DRW_STATE_WRITE_STENCIL = (1 << 27),
DRW_STATE_STENCIL_EQUAL = (1 << 28),
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 9aa5efc837d..a70d80257e6 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -190,8 +190,8 @@ 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_ADDITIVE_FULL,
+ DRW_STATE_BLEND | DRW_STATE_BLEND_PREMUL | DRW_STATE_ADDITIVE |
+ DRW_STATE_MULTIPLY | DRW_STATE_TRANSMISSION | DRW_STATE_ADDITIVE_FULL,
test))
{
if (test) {
@@ -201,6 +201,9 @@ void drw_state_set(DRWState state)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, /* RGB */
GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* Alpha */
}
+ else if ((state & DRW_STATE_BLEND_PREMUL) != 0) {
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ }
else if ((state & DRW_STATE_MULTIPLY) != 0) {
glBlendFunc(GL_DST_COLOR, GL_ZERO);
}
More information about the Bf-blender-cvs
mailing list