diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-05-04 15:07:00 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-05-04 15:08:40 +0300 |
commit | 3f95daa31fa98b1bd67fc71835f0011287c1d136 (patch) | |
tree | 6b171179a5da5ca9b6326bfa5cb56ae7979aeda5 /source/blender/draw/intern/draw_manager_exec.c | |
parent | d8a03c77d796db4ae2546fbcbe230dbf4846b0ea (diff) |
Workbench: Shadows
Initial review of the shard shadows in the workbench engine.
Speed optimizations like transform feedback are not implemented yet. I first want this part to be reviewed and merged.
@fclem please check the note in drw_stencil_set it was holding back nequal == 0 as by default DST.stencil_mask was set to 0. questioin is should we remove the whole check or not.
Also I am still looking for a better name (or split the enum) for DRW_STATE_STENCIL_DEPTH_FAIL_INCR_DECR_WRAP
Reviewers: fclem
Reviewed By: fclem
Tags: #code_quest
Differential Revision: https://developer.blender.org/D3198
Diffstat (limited to 'source/blender/draw/intern/draw_manager_exec.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 232ae36438e..434c021775a 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -278,21 +278,27 @@ void drw_state_set(DRWState state) DRWState test; if (CHANGED_ANY_STORE_VAR( DRW_STATE_WRITE_STENCIL | - DRW_STATE_STENCIL_EQUAL, + DRW_STATE_WRITE_STENCIL_SHADOW | + DRW_STATE_STENCIL_EQUAL | + DRW_STATE_STENCIL_NEQUAL, test)) { if (test) { glEnable(GL_STENCIL_TEST); - /* Stencil Write */ if ((state & DRW_STATE_WRITE_STENCIL) != 0) { glStencilMask(0xFF); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); } + else if ((state & DRW_STATE_WRITE_STENCIL_SHADOW) != 0) { + glStencilMask(0xFF); + glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP); + glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP); + } /* Stencil Test */ - else if ((state & DRW_STATE_STENCIL_EQUAL) != 0) { + else if ((state & (DRW_STATE_STENCIL_EQUAL | DRW_STATE_STENCIL_NEQUAL)) != 0) { glStencilMask(0x00); /* disable write */ - DST.stencil_mask = 0; + DST.stencil_mask = STENCIL_UNDEFINED; } else { BLI_assert(0); @@ -318,15 +324,17 @@ void drw_state_set(DRWState state) static void drw_stencil_set(unsigned int mask) { if (DST.stencil_mask != mask) { + DST.stencil_mask = mask; /* Stencil Write */ if ((DST.state & DRW_STATE_WRITE_STENCIL) != 0) { glStencilFunc(GL_ALWAYS, mask, 0xFF); - DST.stencil_mask = mask; } /* Stencil Test */ else if ((DST.state & DRW_STATE_STENCIL_EQUAL) != 0) { glStencilFunc(GL_EQUAL, mask, 0xFF); - DST.stencil_mask = mask; + } + else if ((DST.state & DRW_STATE_STENCIL_NEQUAL) != 0) { + glStencilFunc(GL_NOTEQUAL, mask, 0xFF); } } } |