summaryrefslogtreecommitdiff
path: root/drivers/gles3
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-02-21 12:30:44 -0300
committerJuan Linietsky <juan@godotengine.org>2019-02-21 12:31:41 -0300
commit8fd2eb6234541dfb34800f7ef4b0350c5795bb67 (patch)
treec52a350d2076dd5268803969439d610685302fb8 /drivers/gles3
parentb52088a64b7daa26e6e5583bff945c02b94432c1 (diff)
Many fixes regarding depth buffer clearing, closes #25994, closes #25975
Diffstat (limited to 'drivers/gles3')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp22
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index c66f2ed6ec..dee01db4a5 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -3286,6 +3286,16 @@ void RasterizerSceneGLES3::_render_mrts(Environment *env, const CameraMatrix &p_
glDisable(GL_CULL_FACE);
glDisable(GL_BLEND);
+ if (!state.used_depth_prepass_and_resolved) {
+ //resolve depth buffer
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, storage->frame.current_rt->buffers.fbo);
+ glReadBuffer(GL_COLOR_ATTACHMENT0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, storage->frame.current_rt->fbo);
+ glBlitFramebuffer(0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, 0, 0, storage->frame.current_rt->width, storage->frame.current_rt->height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ }
+
if (env->ssao_enabled || env->ssr_enabled) {
//copy normal and roughness to effect buffer
@@ -4138,6 +4148,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
glDepthFunc(GL_LEQUAL);
state.used_contact_shadows = false;
+ state.used_depth_prepass_and_resolved = false;
for (int i = 0; i < p_light_cull_count; i++) {
@@ -4185,13 +4196,14 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
//bind depth for read
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 8);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->depth);
+ state.used_depth_prepass_and_resolved = true;
}
fb_cleared = true;
render_pass++;
- state.using_contact_shadows = true;
+ state.used_depth_prepass = true;
} else {
- state.using_contact_shadows = false;
+ state.used_depth_prepass = false;
}
_setup_lights(p_light_cull_result, p_light_cull_count, p_cam_transform.affine_inverse(), p_cam_projection, p_shadow_atlas);
@@ -4288,7 +4300,8 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
}
if (!fb_cleared) {
- glClearBufferfi(GL_DEPTH, 0, 1.0, 0);
+ glClearDepth(1.0f);
+ glClear(GL_DEPTH_BUFFER_BIT);
}
Color clear_color(0, 0, 0, 0);
@@ -4438,6 +4451,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
//state.scene_shader.set_conditional( SceneShaderGLES3::USE_FOG,false);
if (use_mrt) {
+
_render_mrts(env, p_cam_projection);
} else {
//FIXME: check that this is possible to use
@@ -4562,7 +4576,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
float bias = 0;
float normal_bias = 0;
- state.using_contact_shadows = false;
+ state.used_depth_prepass = false;
CameraMatrix light_projection;
Transform light_transform;
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index fbafc59b48..3ac5ade721 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -205,7 +205,8 @@ public:
bool used_sss;
bool used_screen_texture;
bool used_depth_texture;
- bool using_contact_shadows;
+ bool used_depth_prepass;
+ bool used_depth_prepass_and_resolved;
VS::ViewportDebugDraw debug_draw;
} state;