Make alpha 1.0 when using texscreen, fixes #25850

This commit is contained in:
Juan Linietsky 2019-02-21 19:43:34 -03:00
parent 30a4723d9c
commit 5784caae73
2 changed files with 21 additions and 5 deletions

View File

@ -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() {

View File

@ -93,6 +93,7 @@ public:
Transform vp;
Light *using_light;
bool using_shadow;
bool using_transparent_rt;
} state;