diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-07-20 13:40:35 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-07-20 13:41:54 +0300 |
commit | a185bf3b856846b2e300542bacdca3bc119e1bdc (patch) | |
tree | 4dcc7abeeffcdfc94f851ffc7e3dcc9236f0dda2 /source/blender | |
parent | 61c00802d0a9d1698f85633ba1c121b1a17e6425 (diff) |
Workbench: Add backface culling support
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_deferred.c | 6 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_forward.c | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index ce209af8527..4e90a08a543 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -272,6 +272,7 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) WORKBENCH_StorageList *stl = vedata->stl; WORKBENCH_PassList *psl = vedata->psl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + const DRWContextState *draw_ctx = DRW_context_state_get(); if (!stl->g_data) { /* Alloc transient pointers */ @@ -381,7 +382,6 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) } { - const DRWContextState *draw_ctx = DRW_context_state_get(); Scene *scene = draw_ctx->scene; /* AO Samples Tex */ int num_iterations = workbench_taa_calculate_num_iterations(vedata); @@ -405,8 +405,10 @@ void workbench_deferred_engine_init(WORKBENCH_Data *vedata) /* Prepass */ { + const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING)); + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; - psl->prepass_pass = DRW_pass_create("Prepass", state); + psl->prepass_pass = DRW_pass_create("Prepass", (do_cull) ? state | DRW_STATE_CULL_BACK : state); psl->prepass_hair_pass = DRW_pass_create("Prepass", state); } diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 2a65feeb28c..825b80ace52 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -243,6 +243,7 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) WORKBENCH_PassList *psl = vedata->psl; WORKBENCH_StorageList *stl = vedata->stl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); + const DRWContextState *draw_ctx = DRW_context_state_get(); DRWShadingGroup *grp; if (!stl->g_data) { @@ -322,15 +323,17 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata) }); workbench_volume_cache_init(vedata); + const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->flag2 & V3D_BACKFACE_CULLING)); + const int cull_state = (do_cull) ? DRW_STATE_CULL_BACK : 0; /* Transparency Accum */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_OIT | cull_state; psl->transparent_accum_pass = DRW_pass_create("Transparent Accum", state); } /* Depth */ { - int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS; + int state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | cull_state; psl->object_outline_pass = DRW_pass_create("Object Outline Pass", state); } /* Composite */ |