From e06ac4d40cb6871a09adf76729b3f3a7c0e3714a Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Mon, 11 Dec 2023 09:34:03 +1100 Subject: [PATCH] Fix radiance for sky in GLES stereo rendering --- drivers/gles3/rasterizer_scene_gles3.cpp | 14 +++++++++++--- drivers/gles3/storage/light_storage.cpp | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 6cdcbd9f007..a646b1ec7df 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -976,10 +976,10 @@ void RasterizerSceneGLES3::_update_sky_radiance(RID p_env, const Projection &p_p glDisable(GL_BLEND); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); + scene_state.current_depth_test = GLES3::SceneShaderData::DEPTH_TEST_DISABLED; glDisable(GL_SCISSOR_TEST); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - scene_state.cull_mode = GLES3::SceneShaderData::CULL_BACK; + glDisable(GL_CULL_FACE); + scene_state.cull_mode = GLES3::SceneShaderData::CULL_DISABLED; for (int i = 0; i < 6; i++) { Basis local_view = Basis::looking_at(view_normals[i], view_up[i]); @@ -1000,6 +1000,14 @@ void RasterizerSceneGLES3::_update_sky_radiance(RID p_env, const Projection &p_p sky->reflection_dirty = false; } else { if (sky_mode == RS::SKY_MODE_INCREMENTAL && sky->processing_layer < max_processing_layer) { + glDisable(GL_BLEND); + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + scene_state.current_depth_test = GLES3::SceneShaderData::DEPTH_TEST_DISABLED; + glDisable(GL_SCISSOR_TEST); + glDisable(GL_CULL_FACE); + scene_state.cull_mode = GLES3::SceneShaderData::CULL_DISABLED; + _filter_sky_radiance(sky, sky->processing_layer); sky->processing_layer++; } diff --git a/drivers/gles3/storage/light_storage.cpp b/drivers/gles3/storage/light_storage.cpp index af8d629e5a2..2607a133d6d 100644 --- a/drivers/gles3/storage/light_storage.cpp +++ b/drivers/gles3/storage/light_storage.cpp @@ -1121,6 +1121,7 @@ void LightStorage::update_directional_shadow_atlas() { glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, directional_shadow.depth, 0); } + glUseProgram(0); glDepthMask(GL_TRUE); glBindFramebuffer(GL_FRAMEBUFFER, directional_shadow.fbo); RasterizerGLES3::clear_depth(1.0);