Fix: Overlay: Missing backface culling in facing overlay

It was a side effect of enabling the depth write.

The fix is to enable the backface culling when it can
be honored.

However, this only works in solid mode.

Candidate for backporting to 4.2

Fix #126351
This commit is contained in:
Clément Foucault
2024-08-23 17:10:02 +02:00
parent 948d6a8866
commit 0bad30317c

View File

@@ -15,12 +15,19 @@ void OVERLAY_facing_init(OVERLAY_Data * /*vedata*/) {}
void OVERLAY_facing_cache_init(OVERLAY_Data *vedata)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
OVERLAY_PassList *psl = vedata->psl;
OVERLAY_PrivateData *pd = vedata->stl->pd;
for (int i = 0; i < 2; i++) {
/* Non Meshes Pass (Camera, empties, lights ...) */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH;
if (draw_ctx->v3d && draw_ctx->v3d->shading.type == OB_SOLID &&
(draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING))
{
state |= DRW_STATE_CULL_BACK;
}
DRW_PASS_CREATE(psl->facing_ps[i], state | pd->clipping_state);
GPUShader *sh = OVERLAY_shader_facing();