Fix transparent viewport backgrounds with custom clear color
This commit is contained in:
parent
da81ca62a5
commit
6effd3cde7
|
@ -1738,7 +1738,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
|
||||||
RenderDataGLES3 render_data;
|
RenderDataGLES3 render_data;
|
||||||
{
|
{
|
||||||
render_data.render_buffers = rb;
|
render_data.render_buffers = rb;
|
||||||
render_data.transparent_bg = rb.is_valid() ? rb->is_transparent : false;
|
render_data.transparent_bg = rb.is_valid() ? rt->is_transparent : false;
|
||||||
// Our first camera is used by default
|
// Our first camera is used by default
|
||||||
render_data.cam_transform = p_camera_data->main_transform;
|
render_data.cam_transform = p_camera_data->main_transform;
|
||||||
render_data.inv_cam_transform = render_data.cam_transform.affine_inverse();
|
render_data.inv_cam_transform = render_data.cam_transform.affine_inverse();
|
||||||
|
@ -1984,6 +1984,7 @@ void RasterizerSceneGLES3::render_scene(const Ref<RenderSceneBuffers> &p_render_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!keep_color) {
|
if (!keep_color) {
|
||||||
|
clear_color.a = render_data.transparent_bg ? 0.0f : 1.0f;
|
||||||
glClearBufferfv(GL_COLOR, 0, clear_color.components);
|
glClearBufferfv(GL_COLOR, 0, clear_color.components);
|
||||||
}
|
}
|
||||||
RENDER_TIMESTAMP("Render Opaque Pass");
|
RENDER_TIMESTAMP("Render Opaque Pass");
|
||||||
|
|
|
@ -38,8 +38,6 @@ RenderSceneBuffersGLES3::~RenderSceneBuffersGLES3() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSceneBuffersGLES3::configure(const RenderSceneBuffersConfiguration *p_config) {
|
void RenderSceneBuffersGLES3::configure(const RenderSceneBuffersConfiguration *p_config) {
|
||||||
GLES3::TextureStorage *texture_storage = GLES3::TextureStorage::get_singleton();
|
|
||||||
|
|
||||||
//internal_size.x = p_config->get_internal_size().x; // ignore for now
|
//internal_size.x = p_config->get_internal_size().x; // ignore for now
|
||||||
//internal_size.y = p_config->get_internal_size().y;
|
//internal_size.y = p_config->get_internal_size().y;
|
||||||
width = p_config->get_target_size().x;
|
width = p_config->get_target_size().x;
|
||||||
|
@ -54,10 +52,6 @@ void RenderSceneBuffersGLES3::configure(const RenderSceneBuffersConfiguration *p
|
||||||
view_count = p_config->get_view_count();
|
view_count = p_config->get_view_count();
|
||||||
|
|
||||||
free_render_buffer_data();
|
free_render_buffer_data();
|
||||||
|
|
||||||
GLES3::RenderTarget *rt = texture_storage->get_render_target(render_target);
|
|
||||||
|
|
||||||
is_transparent = rt->is_transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSceneBuffersGLES3::free_render_buffer_data() {
|
void RenderSceneBuffersGLES3::free_render_buffer_data() {
|
||||||
|
|
|
@ -58,8 +58,6 @@ public:
|
||||||
//bool use_debanding = false;
|
//bool use_debanding = false;
|
||||||
uint32_t view_count = 1;
|
uint32_t view_count = 1;
|
||||||
|
|
||||||
bool is_transparent = false;
|
|
||||||
|
|
||||||
RID render_target;
|
RID render_target;
|
||||||
|
|
||||||
//built-in textures used for ping pong image processing and blurring
|
//built-in textures used for ping pong image processing and blurring
|
||||||
|
|
|
@ -908,13 +908,19 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
|
||||||
{
|
{
|
||||||
// regular forward for now
|
// regular forward for now
|
||||||
Vector<Color> c;
|
Vector<Color> c;
|
||||||
c.push_back(clear_color.srgb_to_linear()); // our render buffer
|
{
|
||||||
if (rb_data.is_valid()) {
|
Color cc = clear_color.srgb_to_linear();
|
||||||
if (p_render_data->render_buffers->get_msaa_3d() != RS::VIEWPORT_MSAA_DISABLED) {
|
if (rb_data.is_valid()) {
|
||||||
c.push_back(clear_color.srgb_to_linear()); // our resolve buffer
|
cc.a = 0; // For transparent viewport backgrounds.
|
||||||
}
|
}
|
||||||
if (using_subpass_post_process) {
|
c.push_back(cc); // Our render buffer.
|
||||||
c.push_back(Color()); // our 2D buffer we're copying into
|
if (rb_data.is_valid()) {
|
||||||
|
if (p_render_data->render_buffers->get_msaa_3d() != RS::VIEWPORT_MSAA_DISABLED) {
|
||||||
|
c.push_back(clear_color.srgb_to_linear()); // Our resolve buffer.
|
||||||
|
}
|
||||||
|
if (using_subpass_post_process) {
|
||||||
|
c.push_back(Color()); // Our 2D buffer we're copying into.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue