godotengine / godotengine/godot

Fog aerial perspective does not blend seamlessly into the sky

Open
#97,803 5 comments 3 reactions 0 assignees View on GitHub
documentation enhancement topic:3d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

`v4.3.stable.mono.official` [77dcf97d8], also on `v4.3.stable.arch_linux`.

### System information

Godot v4.3.stable.mono - Arch Linux #1 SMP PREEMPT_DYNAMIC Wed, 04 Sep 2024 15:16:37 +0000 - X11 - Vulkan (Forward+) - dedicated AMD Radeon RX 6600 (amdgpu) - 13th Gen Intel(R) Core(TM) i7-13700K (24 Threads)

### Issue description

The [documentation](https://docs.godotengine.org/en/stable/classes/class_environment.html#class-environment-property-fog-aerial-perspective) for `Environment::fog_aerial_perspective` says:

> If set above 0.0 (exclusive), blends between the fog's color and the color of the background [Sky](https://docs.godotengine.org/en/stable/classes/class_sky.html#class-sky).

So if this is set to 1.0, I would expect the fog to be the same colour as the sky. In places where fog density approaches 100%, I would expect to see the sky colour, as if the object has become transparent.

However, that's not what is happening:

![2024-10-04T11:03:29_1152x648](https://github.com/user-attachments/assets/bb434354-be65-413d-8588-82043678c941)

This screenshot was made with a `PanoramaSky` consisting of blue at the top and red at the bottom. Fog density is set to 0.3, and aerial perspective is set to 1.0. The spheres have a green albedo. However, in the distance, the spheres do not become red/blue, but rather an intermediate magenta colour.

From a cursory glance at the code, it seems that the shader is reading from the radiance cube map to do its thing. Could it be that it's reading from the wrong mip level, causing too much blending between the colours? That's just a wild guess though.

### Steps to reproduce

Just open the attached MRP, which consists of the above scene.

### Minimal reproduction project (MRP)

[AerialPerspectiveTest.zip](https://github.com/user-attachments/files/17255993/AerialPerspectiveTest.zip)

Contributor guide

Open the contributing guide

Research direction

Open the attached AerialPerspectiveTest.zip and reproduce the color transition with the PanoramaSky, fog density, and aerial perspective settings described. Then inspect the fog aerial perspective shader and its radiance cube map sampling, including the mip level, to compare the rendered result with the documented sky color. Done means the fog blends into the sky without the unexpected intermediate color.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.