Tested versions
Reproducible in 4.6.stable
System information
Godot v4.6.stable - Windows 11 (build 26100) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.9186) - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 threads) - 15.96 GiB memory
Issue description
When the density of volumetric fog drops low enough it starts appearing yellow. This happens at the edges then the whole volume becomes yellow at low enough density.
This is a visual-breaking issue for game that expect large volumes of low density fog.
Density 0.1

Density 0.01

Density 0.003

See this reddit post for an example of this issue in the wild.
CAUSE and FIX
This is due to the way color data is encoded in volumetric_fog.glsl and decoded in volumetric_fog_process.glsl :
https://github.com/Altarick/godot-sf-factory/blob/755fa449c4aa94fdf2c58e2b726fd62efde07e09/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl#L239-L244
The color data for emission (and scattering) are passed from one shader to the next by encoding them in a single usigned 32 bits integer. This is achieved by packing red and green in 11 bits each, and blue in 10 bits. This means that blue "runs out" of precision before the red and green, resulting in a yellow fog at low densities.
I tested this by restricting all 3 components to 10 bits of precision (see proposed fix). This fixes the issue, at the tradeoff of a higher cutoff for fog visibility : fog is now invisible instead of yellow at very low densities.
Correct color at low density

But no fog at and below 0.001

This is still an improvement since :
- At higher densities there is no longer a yellow halo around fog (in the zone where density was low enough for the bug to be visible)
- Users might not have used fog densities where color was not true anyway
Further work might be needed to improve the rendering of large fog volumes at low density.
Steps to reproduce
To easily see the issue, create a large volume of fog (more than 100m) with low density (below 0.02). White albedo, white emission. If you change lower the density, the fog becomes increasingly yellow.
Minimal reproduction project (MRP)
yellow_fog_mrp.zip
Tested versions
Reproducible in 4.6.stable
System information
Godot v4.6.stable - Windows 11 (build 26100) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.9186) - Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (8 threads) - 15.96 GiB memory
Issue description
When the density of volumetric fog drops low enough it starts appearing yellow. This happens at the edges then the whole volume becomes yellow at low enough density.
This is a visual-breaking issue for game that expect large volumes of low density fog.
Density 0.1

Density 0.01

Density 0.003

See this reddit post for an example of this issue in the wild.
CAUSE and FIX
This is due to the way color data is encoded in volumetric_fog.glsl and decoded in volumetric_fog_process.glsl :
https://github.com/Altarick/godot-sf-factory/blob/755fa449c4aa94fdf2c58e2b726fd62efde07e09/servers/rendering/renderer_rd/shaders/environment/volumetric_fog.glsl#L239-L244
The color data for emission (and scattering) are passed from one shader to the next by encoding them in a single usigned 32 bits integer. This is achieved by packing red and green in 11 bits each, and blue in 10 bits. This means that blue "runs out" of precision before the red and green, resulting in a yellow fog at low densities.
I tested this by restricting all 3 components to 10 bits of precision (see proposed fix). This fixes the issue, at the tradeoff of a higher cutoff for fog visibility : fog is now invisible instead of yellow at very low densities.
Correct color at low density

But no fog at and below 0.001

This is still an improvement since :
Further work might be needed to improve the rendering of large fog volumes at low density.
Steps to reproduce
To easily see the issue, create a large volume of fog (more than 100m) with low density (below 0.02). White albedo, white emission. If you change lower the density, the fog becomes increasingly yellow.
Minimal reproduction project (MRP)
yellow_fog_mrp.zip