Commit: 1f4e9754c02891076ffe5c29a2d7c030aace219c Author: Clément Foucault Date: Thu Jun 27 14:36:40 2019 +0200 Branches: master https://developer.blender.org/rB1f4e9754c02891076ffe5c29a2d7c030aace219c
DRW: Add DRW_STATE_BLEND_CUSTOM This one enable dual source blending, enabling more fine tuned blending parameters inside the shader. =================================================================== 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 392362e73c5..a8f67e10a4d 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -347,12 +347,14 @@ typedef enum { DRW_STATE_BLEND_ALPHA_UNDER_PREMUL = (1 << 20), DRW_STATE_BLEND_OIT = (1 << 21), DRW_STATE_BLEND_MUL = (1 << 22), + /** Use dual source blending. WARNING: Only one color buffer allowed. */ + DRW_STATE_BLEND_CUSTOM = (1 << 23), - DRW_STATE_CLIP_PLANES = (1 << 23), - DRW_STATE_WIRE_SMOOTH = (1 << 24), - DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 25), + DRW_STATE_CLIP_PLANES = (1 << 28), + DRW_STATE_WIRE_SMOOTH = (1 << 29), + DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 30), /** DO NOT USE. Assumed always enabled. Only used internally. */ - DRW_STATE_PROGRAM_POINT_SIZE = (1 << 26), + DRW_STATE_PROGRAM_POINT_SIZE = (1u << 31), } DRWState; #define DRW_STATE_DEFAULT \ diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 2596570c022..949d3e1d38b 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -225,7 +225,7 @@ void drw_state_set(DRWState state) if (CHANGED_ANY_STORE_VAR(DRW_STATE_BLEND_ALPHA | DRW_STATE_BLEND_ALPHA_PREMUL | DRW_STATE_BLEND_ADD | DRW_STATE_BLEND_MUL | DRW_STATE_BLEND_ADD_FULL | DRW_STATE_BLEND_OIT | - DRW_STATE_BLEND_ALPHA_UNDER_PREMUL, + DRW_STATE_BLEND_ALPHA_UNDER_PREMUL | DRW_STATE_BLEND_CUSTOM, test)) { if (test) { glEnable(GL_BLEND); @@ -262,6 +262,11 @@ void drw_state_set(DRWState state) /* Let alpha accumulate. */ glBlendFunc(GL_ONE, GL_ONE); } + else if ((state & DRW_STATE_BLEND_CUSTOM) != 0) { + /* Custom blend parameters using dual source blending. + * Can only be used with one Draw Buffer. */ + glBlendFunc(GL_ONE, GL_SRC1_COLOR); + } else { BLI_assert(0); } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs