godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.26k stars 101 forks source link

Do not render volumetric fog between the camera and the near plane #12610

Open v1993 opened 4 weeks ago

v1993 commented 4 weeks ago

Describe the project you are working on

A 3D top-down game using a distant camera with a narrow FoV for low-but-present perspective distortion (i.e. close to orthogonal but not quite there). Near plane is set to a large value since objects much closer than the gameplay plane should not be visible.

Describe the problem or limitation you are having in your project

Turning on volumetric fog with a relatively low default value really clouds the screen despite camera supposedly not being able to capture objects behind it. Indeed, it seems that fog can't react to non-directional lights placed behind the near plane nor do fog volumes getting culled have any effect, yet global volumetric fog renders there. Presumably, this also means that I'm getting lower quality results than I could due to having to increase length property of the fog.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Treat volumetric fog as starting from the near plane; assume that the volume between the camera and the near plane are fully clear/unaffected as it is generally done for other entities. I don't think there's a case where the current behavior is desirable as fog is not accounting for lights and fog volumes getting culled, but if someone has one, this probably could be made into a toggle.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Presumably fog depth is switched to being computed as distance from the near plane to the closest object instead of distance from the camera to the closest object.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I thing lowering fog density and lowed detail spread somewhat mitigates the issue but the result is still not quite like I'd like it to be (e.g. editor camera now sees things very clearly compared to the in-game camera preview). This also does not resolve volumetric fog between the camera and the near plane not reacting to fog volumes (which is understandable with how it currently works but undesirable).

Is there a reason why this should be core and not an add-on in the asset library?

Volumetric fog is a part of core rendering functionality.

v1993 commented 3 weeks ago

After thinking about for a bit more, another workaround is to avoid using global fog (or set it to a very low value) and exclusively rely on fog volumes for areas where gameplay takes place. It doesn't fix the problem completely but might be enough for some use cases.