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.
This commit is contained in:
rsjtdrjgfuzkfg 2023-02-16 23:53:43 +01:00
parent 29f670b7ab
commit 7f8fa79e94

View file

@ -1895,6 +1895,10 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &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<RenderSceneBuffers> &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);