Workbench: Add backface culling support

This commit is contained in:
Clément Foucault 2018-07-20 12:40:35 +02:00
parent 61c00802d0
commit a185bf3b85
2 changed files with 9 additions and 4 deletions

View File

@ -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);
}

View File

@ -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 */