Merge pull request #61171 from clayjohn/Dof-tonemap-bugs
Fixed recent DoF and tonemap bugs
This commit is contained in:
commit
d8650fb182
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue