This commit is contained in:
parent
b52088a64b
commit
8fd2eb6234
2 changed files with 20 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue