diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2020-10-15 21:59:08 +0200 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2020-10-15 21:59:08 +0200 |
commit | 4357506e64784f84ada8d84caade8172a4f89a79 (patch) | |
tree | 53c6138f99c720bcf6a08941354dec59c5d21f3c /servers/rendering/rasterizer_rd/shaders | |
parent | 4dce52e4cb0b5438ae22c3273ba5b1da12986dbe (diff) |
Fix "fixed" fog drawing in front of volumetric fog with a sky background
This closes #42820.
Co-authored-by: Clay John <claynjohn@gmail.com>
Diffstat (limited to 'servers/rendering/rasterizer_rd/shaders')
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl | 18 | ||||
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/sky.glsl | 9 |
2 files changed, 15 insertions, 12 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl index e11f3983c5..be34473892 100644 --- a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl +++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl @@ -2726,14 +2726,15 @@ FRAGMENT_SHADER_CODE specular_buffer = vec4(specular_light, metallic); #endif - if (scene_data.volumetric_fog_enabled) { - vec4 fog = volumetric_fog_process(screen_uv, -vertex.z); + // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky. + if (scene_data.fog_enabled) { + vec4 fog = fog_process(vertex); diffuse_buffer.rgb = mix(diffuse_buffer.rgb, fog.rgb, fog.a); specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a); } - if (scene_data.fog_enabled) { - vec4 fog = fog_process(vertex); + if (scene_data.volumetric_fog_enabled) { + vec4 fog = volumetric_fog_process(screen_uv, -vertex.z); diffuse_buffer.rgb = mix(diffuse_buffer.rgb, fog.rgb, fog.a); specular_buffer.rgb = mix(specular_buffer.rgb, vec3(0.0), fog.a); } @@ -2747,13 +2748,14 @@ FRAGMENT_SHADER_CODE //frag_color = vec4(1.0); #endif //USE_NO_SHADING - if (scene_data.volumetric_fog_enabled) { - vec4 fog = volumetric_fog_process(screen_uv, -vertex.z); + // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky. + if (scene_data.fog_enabled) { + vec4 fog = fog_process(vertex); frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); } - if (scene_data.fog_enabled) { - vec4 fog = fog_process(vertex); + if (scene_data.volumetric_fog_enabled) { + vec4 fog = volumetric_fog_process(screen_uv, -vertex.z); frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); } diff --git a/servers/rendering/rasterizer_rd/shaders/sky.glsl b/servers/rendering/rasterizer_rd/shaders/sky.glsl index 7b6de6a555..7711f683ae 100644 --- a/servers/rendering/rasterizer_rd/shaders/sky.glsl +++ b/servers/rendering/rasterizer_rd/shaders/sky.glsl @@ -223,13 +223,14 @@ FRAGMENT_SHADER_CODE #if !defined(DISABLE_FOG) && !defined(USE_CUBEMAP_PASS) - if (scene_data.volumetric_fog_enabled) { - vec4 fog = volumetric_fog_process(uv); + // Draw "fixed" fog before volumetric fog to ensure volumetric fog can appear in front of the sky. + if (scene_data.fog_enabled) { + vec4 fog = fog_process(cube_normal); frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); } - if (scene_data.fog_enabled) { - vec4 fog = fog_process(cube_normal); + if (scene_data.volumetric_fog_enabled) { + vec4 fog = volumetric_fog_process(uv); frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a); } |