From 699e9f79669ce4759e4e899f68051cb36e5ee7ba Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 23 Feb 2022 23:54:06 +0100 Subject: Add Environment properties to control fog rendering on background sky Values lower than 1.0 can be used to make the fog rendering not fully obstruct the sky. This can be desired when using fog as a purely atmospheric effect, without intending to use fog for open world fog fading. When set to 0.0, fog rendering behavior will be similar to Godot 3.x where sky rendering was never affected by fog. --- servers/rendering/renderer_rd/environment/sky.cpp | 3 +++ servers/rendering/renderer_rd/environment/sky.h | 31 +++++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) (limited to 'servers/rendering/renderer_rd/environment') diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp index 1d6b158d65..671fa14900 100644 --- a/servers/rendering/renderer_rd/environment/sky.cpp +++ b/servers/rendering/renderer_rd/environment/sky.cpp @@ -1319,6 +1319,9 @@ void SkyRD::setup(RID p_env, RID p_render_buffers, const PagedArray &p_ligh sky_scene_state.ubo.fog_light_color[2] = fog_color.b * fog_energy; sky_scene_state.ubo.fog_sun_scatter = RendererSceneRenderRD::get_singleton()->environment_get_fog_sun_scatter(p_env); + sky_scene_state.ubo.fog_sky_affect = RendererSceneRenderRD::get_singleton()->environment_get_fog_sky_affect(p_env); + sky_scene_state.ubo.volumetric_fog_sky_affect = RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_sky_affect(p_env); + RD::get_singleton()->buffer_update(sky_scene_state.uniform_buffer, 0, sizeof(SkySceneState::UBO), &sky_scene_state.ubo); } diff --git a/servers/rendering/renderer_rd/environment/sky.h b/servers/rendering/renderer_rd/environment/sky.h index 080165c112..3534e9b571 100644 --- a/servers/rendering/renderer_rd/environment/sky.h +++ b/servers/rendering/renderer_rd/environment/sky.h @@ -148,20 +148,23 @@ private: public: struct SkySceneState { struct UBO { - uint32_t volumetric_fog_enabled; - float volumetric_fog_inv_length; - float volumetric_fog_detail_spread; - - float fog_aerial_perspective; - - float fog_light_color[3]; - float fog_sun_scatter; - - uint32_t fog_enabled; - float fog_density; - - float z_far; - uint32_t directional_light_count; + uint32_t volumetric_fog_enabled; // 4 - 4 + float volumetric_fog_inv_length; // 4 - 8 + float volumetric_fog_detail_spread; // 4 - 12 + float volumetric_fog_sky_affect; // 4 - 16 + + uint32_t fog_enabled; // 4 - 20 + float fog_sky_affect; // 4 - 24 + float fog_density; // 4 - 28 + float fog_sun_scatter; // 4 - 32 + + float fog_light_color[3]; // 12 - 44 + float fog_aerial_perspective; // 4 - 48 + + float z_far; // 4 - 52 + uint32_t directional_light_count; // 4 - 56 + uint32_t pad1; // 4 - 60 + uint32_t pad2; // 4 - 64 }; UBO ubo; -- cgit v1.2.3