diff options
author | Yuri Rubinsky <chaosus89@gmail.com> | 2022-05-17 10:55:50 +0300 |
---|---|---|
committer | Yuri Rubinsky <chaosus89@gmail.com> | 2022-05-18 06:43:07 +0300 |
commit | 5322b171de1dedc8780180e9026e115afd2abaef (patch) | |
tree | f35a1510ecfff8a7eeada21052451c6f55b22c76 /servers | |
parent | 5631b59e218f4883442382c097eed10ed76b3c8d (diff) |
Fix tonemapper shader to correctly apply alpha channel
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp | 2 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shaders/effects/tonemap.glsl | 25 |
2 files changed, 14 insertions, 13 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index 0eb981d51b..7b92e92f8c 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -1523,7 +1523,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co Vector<Color> c; { Color cc = clear_color.srgb_to_linear(); - if (using_separate_specular) { + if (using_separate_specular || render_buffer) { cc.a = 0; //subsurf scatter must be 0 } c.push_back(cc); diff --git a/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl b/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl index 5a238452c0..a8ccdea60b 100644 --- a/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/tonemap.glsl @@ -426,12 +426,13 @@ vec3 screen_space_dither(vec2 frag_coord) { void main() { #ifdef SUBPASS // SUBPASS and MULTIVIEW can be combined but in that case we're already reading from the correct layer - vec3 color = subpassLoad(input_color).rgb * params.luminance_multiplier; + vec4 color = subpassLoad(input_color); #elif defined(MULTIVIEW) - vec3 color = textureLod(source_color, vec3(uv_interp, ViewIndex), 0.0f).rgb * params.luminance_multiplier; + vec4 color = textureLod(source_color, vec3(uv_interp, ViewIndex), 0.0f); #else - vec3 color = textureLod(source_color, uv_interp, 0.0f).rgb * params.luminance_multiplier; + vec4 color = textureLod(source_color, uv_interp, 0.0f); #endif + color.rgb *= params.luminance_multiplier; // Exposure @@ -443,7 +444,7 @@ void main() { } #endif - color *= exposure; + color.rgb *= exposure; // Early Tonemap & SRGB Conversion #ifndef SUBPASS @@ -456,19 +457,19 @@ void main() { } if (params.use_fxaa) { - color = do_fxaa(color, exposure, uv_interp); + color.rgb = do_fxaa(color.rgb, exposure, uv_interp); } #endif if (params.use_debanding) { // For best results, debanding should be done before tonemapping. // Otherwise, we're adding noise to an already-quantized image. - color += screen_space_dither(gl_FragCoord.xy); + color.rgb += screen_space_dither(gl_FragCoord.xy); } - color = apply_tonemapping(color, params.white); + color.rgb = apply_tonemapping(color.rgb, params.white); - color = linear_to_srgb(color); // regular linear -> SRGB conversion + color.rgb = linear_to_srgb(color.rgb); // regular linear -> SRGB conversion #ifndef SUBPASS // Glow @@ -482,19 +483,19 @@ void main() { glow = apply_tonemapping(glow, params.white); glow = linear_to_srgb(glow); - color = apply_glow(color, glow); + color.rgb = apply_glow(color.rgb, glow); } #endif // Additional effects if (params.use_bcs) { - color = apply_bcs(color, params.bcs); + color.rgb = apply_bcs(color.rgb, params.bcs); } if (params.use_color_correction) { - color = apply_color_correction(color); + color.rgb = apply_color_correction(color.rgb); } - frag_color = vec4(color, 1.0f); + frag_color = color; } |