diff --git a/drivers/gles2/shaders/tonemap.glsl b/drivers/gles2/shaders/tonemap.glsl index f550b46f4f1..aaa6ae5498f 100644 --- a/drivers/gles2/shaders/tonemap.glsl +++ b/drivers/gles2/shaders/tonemap.glsl @@ -204,7 +204,7 @@ vec4 apply_glow(vec4 color, vec3 glow) { // apply glow using the selected blendi #ifndef USE_GLOW_SOFTLIGHT // softlight has no effect on black color // compute the alpha from glow float a = max(max(glow.r, glow.g), glow.b); - color.a = a + color.a * (1 - a); + color.a = a + color.a * (1.0 - a); if (color.a == 0.0) { color.rgb = vec3(0.0); } else if (color.a < 1.0) { @@ -242,10 +242,10 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) { vec4 rgbSE = texture2DLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0); vec3 rgbM = color.rgb; vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW.rgb, luma) - ((1 - rgbNW.a) / 8.0); - float lumaNE = dot(rgbNE.rgb, luma) - ((1 - rgbNE.a) / 8.0); - float lumaSW = dot(rgbSW.rgb, luma) - ((1 - rgbSW.a) / 8.0); - float lumaSE = dot(rgbSE.rgb, luma) - ((1 - rgbSE.a) / 8.0); + float lumaNW = dot(rgbNW.rgb, luma) - ((1.0 - rgbNW.a) / 8.0); + float lumaNE = dot(rgbNE.rgb, luma) - ((1.0 - rgbNE.a) / 8.0); + float lumaSW = dot(rgbSW.rgb, luma) - ((1.0 - rgbSW.a) / 8.0); + float lumaSE = dot(rgbSE.rgb, luma) - ((1.0 - rgbSE.a) / 8.0); float lumaM = dot(rgbM, luma) - (color.a / 8.0); float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); @@ -267,7 +267,7 @@ vec4 apply_fxaa(vec4 color, vec2 uv_interp, vec2 pixel_size) { vec4 rgbA = 0.5 * (texture2DLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0) + texture2DLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0)); vec4 rgbB = rgbA * 0.5 + 0.25 * (texture2DLod(source, uv_interp + dir * -0.5, 0.0) + texture2DLod(source, uv_interp + dir * 0.5, 0.0)); - float lumaB = dot(rgbB.rgb, luma) - ((1 - rgbB.a) / 8.0); + float lumaB = dot(rgbB.rgb, luma) - ((1.0 - rgbB.a) / 8.0); vec4 color_output = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB; if (color_output.a == 0.0) { color_output.rgb = vec3(0.0); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index acbf943c394..f0d8d63d0b1 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3742,7 +3742,8 @@ void RasterizerSceneGLES3::_post_process(Environment *env, const CameraMatrix &p if (composite_from != storage->frame.current_rt->buffers.diffuse) { glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // Alpha was used by the horizontal pass, it should not carry over. + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); } else { glActiveTexture(GL_TEXTURE2); diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl index 1167da49054..7936d2d42b5 100644 --- a/drivers/gles3/shaders/effect_blur.glsl +++ b/drivers/gles3/shaders/effect_blur.glsl @@ -240,7 +240,6 @@ void main() { vec4 color_accum = vec4(0.0); float max_accum = 0.0; - float k_accum = 0.0; for (int i = 0; i < dof_kernel_size; i++) { int int_ofs = i - dof_kernel_from; @@ -250,7 +249,6 @@ void main() { float tap_k = dof_kernel[i]; vec4 tap_color = textureLod(source_color, tap_uv, 0.0); - float w = tap_color.a; float tap_depth = texture(dof_source_depth, tap_uv, 0.0).r; tap_depth = tap_depth * 2.0 - 1.0; @@ -270,14 +268,9 @@ void main() { max_accum = max(max_accum, tap_amount * ofs_influence); - k_accum += w; - tap_color.rgb *= w; color_accum += tap_color * tap_k; } - if (k_accum > 0.0) { - color_accum.rgb /= k_accum / dof_kernel_size; - } color_accum.a = max(color_accum.a, sqrt(max_accum)); #ifdef DOF_NEAR_BLUR_MERGE diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl index 81ed00fa97c..f2639772ce6 100644 --- a/drivers/gles3/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -292,7 +292,7 @@ vec4 apply_glow(vec4 color, vec3 glow) { // apply glow using the selected blendi #ifndef USE_GLOW_SOFTLIGHT // softlight has no effect on black color // compute the alpha from glow float a = max(max(glow.r, glow.g), glow.b); - color.a = a + color.a * (1 - a); + color.a = a + color.a * (1.0 - a); if (color.a == 0.0) { color.rgb = vec3(0.0); } else if (color.a < 1.0) { @@ -330,10 +330,10 @@ vec4 apply_fxaa(vec4 color, float exposure, vec2 uv_interp, vec2 pixel_size) { vec4 rgbSE = textureLod(source, uv_interp + vec2(1.0, 1.0) * pixel_size, 0.0); vec3 rgbM = color.rgb; vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW.rgb * exposure, luma) - ((1 - rgbNW.a) / 8.0); - float lumaNE = dot(rgbNE.rgb * exposure, luma) - ((1 - rgbNE.a) / 8.0); - float lumaSW = dot(rgbSW.rgb * exposure, luma) - ((1 - rgbSW.a) / 8.0); - float lumaSE = dot(rgbSE.rgb * exposure, luma) - ((1 - rgbSE.a) / 8.0); + float lumaNW = dot(rgbNW.rgb * exposure, luma) - ((1.0 - rgbNW.a) / 8.0); + float lumaNE = dot(rgbNE.rgb * exposure, luma) - ((1.0 - rgbNE.a) / 8.0); + float lumaSW = dot(rgbSW.rgb * exposure, luma) - ((1.0 - rgbSW.a) / 8.0); + float lumaSE = dot(rgbSE.rgb * exposure, luma) - ((1.0 - rgbSE.a) / 8.0); float lumaM = dot(rgbM * exposure, luma) - (color.a / 8.0); float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); @@ -355,7 +355,7 @@ vec4 apply_fxaa(vec4 color, float exposure, vec2 uv_interp, vec2 pixel_size) { vec4 rgbA = 0.5 * exposure * (textureLod(source, uv_interp + dir * (1.0 / 3.0 - 0.5), 0.0) + textureLod(source, uv_interp + dir * (2.0 / 3.0 - 0.5), 0.0)); vec4 rgbB = rgbA * 0.5 + 0.25 * exposure * (textureLod(source, uv_interp + dir * -0.5, 0.0) + textureLod(source, uv_interp + dir * 0.5, 0.0)); - float lumaB = dot(rgbB.rgb, luma) - ((1 - rgbB.a) / 8.0); + float lumaB = dot(rgbB.rgb, luma) - ((1.0 - rgbB.a) / 8.0); vec4 color_output = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB; if (color_output.a == 0.0) { color_output.rgb = vec3(0.0);