Fixed sky reflection rendering when transparent BG
(cherry picked from commit c34f18acce
)
This commit is contained in:
parent
5975b44ded
commit
c7040f3218
|
@ -4234,17 +4234,14 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||||
|
|
||||||
clear_color = env->bg_color.to_linear();
|
clear_color = env->bg_color.to_linear();
|
||||||
storage->frame.clear_request = false;
|
storage->frame.clear_request = false;
|
||||||
} else if (env->bg_mode == VS::ENV_BG_SKY || env->bg_mode == VS::ENV_BG_COLOR_SKY) {
|
} else if (env->bg_mode == VS::ENV_BG_SKY) {
|
||||||
|
|
||||||
sky = storage->sky_owner.getornull(env->sky);
|
|
||||||
|
|
||||||
if (sky) {
|
|
||||||
env_radiance_tex = sky->radiance;
|
|
||||||
}
|
|
||||||
storage->frame.clear_request = false;
|
storage->frame.clear_request = false;
|
||||||
if (env->bg_mode == VS::ENV_BG_COLOR_SKY) {
|
|
||||||
clear_color = env->bg_color.to_linear();
|
} else if (env->bg_mode == VS::ENV_BG_COLOR_SKY) {
|
||||||
}
|
|
||||||
|
clear_color = env->bg_color.to_linear();
|
||||||
|
storage->frame.clear_request = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
storage->frame.clear_request = false;
|
storage->frame.clear_request = false;
|
||||||
|
@ -4254,34 +4251,48 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const
|
||||||
glClearBufferfv(GL_COLOR, 0, clear_color.components); // specular
|
glClearBufferfv(GL_COLOR, 0, clear_color.components); // specular
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env && env->bg_mode == VS::ENV_BG_CANVAS) {
|
if (env) {
|
||||||
//copy canvas to 3d buffer and convert it to linear
|
switch (env->bg_mode) {
|
||||||
|
case VS::ENV_BG_COLOR_SKY:
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
case VS::ENV_BG_SKY:
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
sky = storage->sky_owner.getornull(env->sky);
|
||||||
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
|
|
||||||
|
|
||||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, true);
|
if (sky) {
|
||||||
|
env_radiance_tex = sky->radiance;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case VS::ENV_BG_CANVAS:
|
||||||
|
//copy canvas to 3d buffer and convert it to linear
|
||||||
|
|
||||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, true);
|
glDisable(GL_BLEND);
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
storage->shaders.copy.bind();
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
|
||||||
|
|
||||||
_copy_screen(true, true);
|
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, true);
|
||||||
|
|
||||||
//turn off everything used
|
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, true);
|
||||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, false);
|
|
||||||
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false);
|
|
||||||
|
|
||||||
//restore
|
storage->shaders.copy.bind();
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glDepthMask(GL_TRUE);
|
_copy_screen(true, true);
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glEnable(GL_CULL_FACE);
|
//turn off everything used
|
||||||
|
storage->shaders.copy.set_conditional(CopyShaderGLES3::SRGB_TO_LINEAR, false);
|
||||||
|
storage->shaders.copy.set_conditional(CopyShaderGLES3::DISABLE_ALPHA, false);
|
||||||
|
|
||||||
|
//restore
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.texscreen_copied = false;
|
state.texscreen_copied = false;
|
||||||
|
|
Loading…
Reference in New Issue