Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-06-17 16:18:21 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-06-17 17:13:28 +0300
commit80fb263aa9ecca5f4483504c1c64e6c4f55ed041 (patch)
tree39652b5fc6576ad5002b5fa4ff2692ef178b7b92 /source/blender/draw/engines/workbench/workbench_deferred.c
parent6ae2de026622e8e77d5d9682160c6347e0b65b59 (diff)
DRW: Make stencil state clearer and distinct
Write and test states are now separate and need to be explicit. Also add asserts when trying to write without test enabled.
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_deferred.c')
-rw-r--r--source/blender/draw/engines/workbench/workbench_deferred.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 28ac6d0c274..f2f211d1db9 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -760,8 +760,10 @@ void workbench_deferred_cache_init(WORKBENCH_Data *vedata)
DRWState depth_fail_state = DRW_STATE_DEPTH_GREATER_EQUAL | DRW_STATE_WRITE_COLOR |
DRW_STATE_BLEND_ADD;
#else
- DRWState depth_pass_state = DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_STENCIL_SHADOW_PASS;
- DRWState depth_fail_state = DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL;
+ DRWState depth_pass_state = DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_STENCIL_SHADOW_PASS |
+ DRW_STATE_STENCIL_ALWAYS;
+ DRWState depth_fail_state = DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL |
+ DRW_STATE_STENCIL_ALWAYS;
#endif
psl->shadow_depth_pass_pass = DRW_pass_create("Shadow Pass", depth_pass_state);
psl->shadow_depth_pass_mani_pass = DRW_pass_create("Shadow Pass Mani", depth_pass_state);
@@ -1246,11 +1248,11 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
DRW_draw_pass(psl->shadow_depth_fail_caps_mani_pass);
if (GHOST_ENABLED(psl)) {
- /* We need to set the stencil buffer to 0 where Ghost objects
+ /* We need to set the stencil buffer to 0 where Ghost objects are
* else they will get shadow and even badly shadowed. */
- DRW_pass_state_set(psl->ghost_prepass_pass, DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL);
- DRW_pass_state_set(psl->ghost_prepass_hair_pass,
- DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL);
+ DRWState state = DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+ DRW_pass_state_set(psl->ghost_prepass_pass, state);
+ DRW_pass_state_set(psl->ghost_prepass_hair_pass, state);
DRW_draw_pass(psl->ghost_prepass_pass);
DRW_draw_pass(psl->ghost_prepass_hair_pass);
@@ -1274,9 +1276,9 @@ void workbench_deferred_draw_scene(WORKBENCH_Data *vedata)
GPU_framebuffer_bind(dfbl->depth_only_fb);
GPU_framebuffer_clear_stencil(dfbl->depth_only_fb, 0xFF);
- DRW_pass_state_set(psl->ghost_prepass_pass, DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL);
- DRW_pass_state_set(psl->ghost_prepass_hair_pass,
- DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL);
+ DRWState state = DRW_STATE_DEPTH_EQUAL | DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+ DRW_pass_state_set(psl->ghost_prepass_pass, state);
+ DRW_pass_state_set(psl->ghost_prepass_hair_pass, state);
DRW_draw_pass(psl->ghost_prepass_pass);
DRW_draw_pass(psl->ghost_prepass_hair_pass);