From 7f8fa79e9454a7b8769f9159810067141e17dbba Mon Sep 17 00:00:00 2001 From: rsjtdrjgfuzkfg Date: Thu, 16 Feb 2023 23:53:43 +0100 Subject: [PATCH] OpenGL: fix culling without depth prepass This commit ensures a known backface culling state when rendering, even if no depth prepass is used. This fixes backside culling not being applied properly in some situations, most notably in scenes that only use backside culling on mobile platforms. --- drivers/gles3/rasterizer_scene_gles3.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 1a18f35e64f..6cc6b8224c3 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1895,6 +1895,10 @@ void RasterizerSceneGLES3::render_scene(const Ref &p_render_ glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo); glViewport(0, 0, rb->width, rb->height); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + scene_state.cull_mode = GLES3::SceneShaderData::CULL_BACK; + // Do depth prepass if it's explicitly enabled bool use_depth_prepass = config->use_depth_prepass; @@ -1910,9 +1914,6 @@ void RasterizerSceneGLES3::render_scene(const Ref &p_render_ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glDisable(GL_SCISSOR_TEST); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - scene_state.cull_mode = GLES3::SceneShaderData::CULL_BACK; glColorMask(0, 0, 0, 0); glClearDepth(1.0f);