diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-13 09:05:30 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-13 09:05:30 +0200 |
commit | 0aa2d7061398a2d65823469d64add663802ea5bd (patch) | |
tree | f40fcde5393be3c20e43b4f0492d1cc068987abe | |
parent | b9e924c806870d1c9dc8705d5af9230504e737da (diff) | |
parent | 6aebc7b66efe9cfd562f702b86f0fac070ee2ec2 (diff) |
Merge pull request #67320 from Calinou/fix-volumetric-fog-low-density
Fix volumetric fog not rendering at densities lower than or equal to 0.001
-rw-r--r-- | doc/classes/Environment.xml | 1 | ||||
-rw-r--r-- | doc/classes/FogMaterial.xml | 1 | ||||
-rw-r--r-- | servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index 243a28e73d..33b6a786ae 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -301,6 +301,7 @@ <member name="volumetric_fog_density" type="float" setter="set_volumetric_fog_density" getter="get_volumetric_fog_density" default="0.05"> The base [i]exponential[/i] density of the volumetric fog. Set this to the lowest density you want to have globally. [FogVolume]s can be used to add to or subtract from this density in specific areas. Fog rendering is exponential as in real life. A value of [code]0.0[/code] disables global volumetric fog while allowing [FogVolume]s to display volumetric fog in specific areas. + To make volumetric fog work as a volumetric [i]lighting[/i] solution, set [member volumetric_fog_density] to the lowest non-zero value ([code]0.0001[/code]) then increase lights' [member Light3D.light_volumetric_fog_energy] to values between [code]10000[/code] and [code]100000[/code] to compensate for the very low density. </member> <member name="volumetric_fog_detail_spread" type="float" setter="set_volumetric_fog_detail_spread" getter="get_volumetric_fog_detail_spread" default="2.0"> The distribution of size down the length of the froxel buffer. A higher value compresses the froxels closer to the camera and places more detail closer to the camera. diff --git a/doc/classes/FogMaterial.xml b/doc/classes/FogMaterial.xml index 7428d6169a..aab6be4212 100644 --- a/doc/classes/FogMaterial.xml +++ b/doc/classes/FogMaterial.xml @@ -15,6 +15,7 @@ </member> <member name="density" type="float" setter="set_density" getter="get_density" default="1.0"> The density of the [FogVolume]. Denser objects are more opaque, but may suffer from under-sampling artifacts that look like stripes. Negative values can be used to subtract fog from other [FogVolume]s or global volumetric fog. + [b]Note:[/b] Due to limited precision, [member density] values between [code]-0.001[/code] and [code]0.001[/code] (exclusive) act like [code]0.0[/code]. This does not apply to [member Environment.volumetric_fog_density]. </member> <member name="density_texture" type="Texture3D" setter="set_density_texture" getter="get_density_texture"> The 3D texture that is used to scale the [member density] of the [FogVolume]. This can be used to vary fog density within the [FogVolume] with any kind of static pattern. For animated effects, consider using a custom [url=$DOCS_URL/tutorials/shaders/shader_reference/fog_shader.html]fog shader[/url]. diff --git a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl index eed9038502..28507e6c12 100644 --- a/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl @@ -381,7 +381,7 @@ void main() { float cell_depth_size = abs(view_pos.z - get_depth_at_pos(fog_cell_size.z, pos.z + 1)); //compute directional lights - if (total_density > 0.001) { + if (total_density > 0.00005) { for (uint i = 0; i < params.directional_light_count; i++) { if (directional_lights.data[i].volumetric_fog_energy > 0.001) { vec3 shadow_attenuation = vec3(1.0); |