summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-10-15 22:34:40 +0200
committerGitHub <noreply@github.com>2020-10-15 22:34:40 +0200
commit1b443da1827e312db1aa99e3895c1879caf246ca (patch)
tree53c6138f99c720bcf6a08941354dec59c5d21f3c
parent4dce52e4cb0b5438ae22c3273ba5b1da12986dbe (diff)
parent4357506e64784f84ada8d84caade8172a4f89a79 (diff)
Merge pull request #42837 from Calinou/fix-fog-volumetric-sky
Fix "fixed" fog drawing in front of volumetric fog with a sky background
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl18
-rw-r--r--servers/rendering/rasterizer_rd/shaders/sky.glsl9
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);
}