summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2019-02-21 19:43:34 -0300
committerJuan Linietsky <juan@godotengine.org>2019-02-21 19:43:34 -0300
commit5784caae73dbb9dcb1e6640884782859c5ab94b6 (patch)
tree7ee422598b5a7f5fd1c358c2dce7e152d27609ba /drivers
parent30a4723d9c974daaaf6b8af581b2d66c6b31b119 (diff)
Make alpha 1.0 when using texscreen, fixes #25850
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.cpp25
-rw-r--r--drivers/gles2/rasterizer_canvas_gles2.h1
2 files changed, 21 insertions, 5 deletions
diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp
index bf210ef2b2..7d643330cc 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.cpp
+++ b/drivers/gles2/rasterizer_canvas_gles2.cpp
@@ -112,11 +112,11 @@ void RasterizerCanvasGLES2::_set_uniforms() {
void RasterizerCanvasGLES2::canvas_begin() {
state.canvas_shader.bind();
- bool transparent = false;
+ state.using_transparent_rt = false;
if (storage->frame.current_rt) {
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo);
glColorMask(1, 1, 1, 1);
- transparent = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
+ state.using_transparent_rt = storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT];
}
if (storage->frame.clear_request) {
@@ -124,12 +124,12 @@ void RasterizerCanvasGLES2::canvas_begin() {
glClearColor(storage->frame.clear_request_color.r,
storage->frame.clear_request_color.g,
storage->frame.clear_request_color.b,
- transparent ? storage->frame.clear_request_color.a : 1.0);
+ state.using_transparent_rt ? storage->frame.clear_request_color.a : 1.0);
glClear(GL_COLOR_BUFFER_BIT);
storage->frame.clear_request = false;
}
- glColorMask(1, 1, 1, transparent ? 1 : 0);
+ glColorMask(1, 1, 1, state.using_transparent_rt ? 1 : 0);
/*
if (storage->frame.current_rt) {
@@ -186,7 +186,10 @@ void RasterizerCanvasGLES2::canvas_end() {
state.using_texture_rect = false;
state.using_skeleton = false;
state.using_ninepatch = false;
- glColorMask(1, 1, 1, 1);
+ if (state.using_transparent_rt) {
+ glColorMask(1, 1, 1, 1);
+ }
+ state.using_transparent_rt = false;
}
RasterizerStorageGLES2::Texture *RasterizerCanvasGLES2::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
@@ -1179,6 +1182,10 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
ERR_FAIL();
}
+ if (state.using_transparent_rt) {
+ glColorMask(1, 1, 1, 1);
+ }
+
glDisable(GL_BLEND);
Vector2 wh(storage->frame.current_rt->width, storage->frame.current_rt->height);
@@ -1189,6 +1196,8 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, true);
}
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, !state.using_transparent_rt);
+
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->copy_screen_effect.fbo);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, storage->frame.current_rt->color);
@@ -1218,6 +1227,11 @@ void RasterizerCanvasGLES2::_copy_screen(const Rect2 &p_rect) {
_draw_polygon(indexpos, 6, 4, vertpos, uvpos, NULL, false);
storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_COPY_SECTION, false);
+ storage->shaders.copy.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, false);
+
+ if (state.using_transparent_rt) {
+ glColorMask(1, 1, 1, 0);
+ }
glBindFramebuffer(GL_FRAMEBUFFER, storage->frame.current_rt->fbo); //back to front
glEnable(GL_BLEND);
@@ -2008,6 +2022,7 @@ void RasterizerCanvasGLES2::initialize() {
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false));
state.using_light = NULL;
+ state.using_transparent_rt = false;
}
void RasterizerCanvasGLES2::finalize() {
diff --git a/drivers/gles2/rasterizer_canvas_gles2.h b/drivers/gles2/rasterizer_canvas_gles2.h
index 0d069ebabc..af41e91e0c 100644
--- a/drivers/gles2/rasterizer_canvas_gles2.h
+++ b/drivers/gles2/rasterizer_canvas_gles2.h
@@ -93,6 +93,7 @@ public:
Transform vp;
Light *using_light;
bool using_shadow;
+ bool using_transparent_rt;
} state;