Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make depth fog aerial perspective use the first radiance mipmap #89995

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Mar 28, 2024

This makes the depth fog fade directly to the sharpest possible version of the sky, as opposed to a blurred version that is less suitable for open world fog fading.

Subtle differences may still be noticeable when using a sky material with nearest-neighbor filtered textures, as it's always sampled with bilinear filtering. I've been wondering how we can improve upon this (perhaps with a project setting to adjust this sampler like godotengine/godot-proposals#8063), but it's not too noticeable in practice if your Camera3D's Far property is adjusted to match the fog's end distance. Doing so is also beneficial for performance anyway.

Given this makes #84792 a lot more useful for open world games and affects visuals of projects using that feature, it would be good to get this in for 4.3 if possible 🙂

The appearance of exponential fog isn't affected by this PR.

Testing project: test_fog_sky_fade.zip

Preview

Forward+

Before After
Screenshot_20240328_214643 webp Screenshot_20240328_220355 webp

Mobile

Fog aerial perspective appears darker in general (both without and with this PR), similar to its screen_texture issue where screen contents appear darker.

Before After
Screenshot_20240328_221536 png webp Screenshot_20240328_221523 png webp

Compatibility

Fog aerial perspective isn't implemented yet in the Compatibility rendering method.

This makes the depth fog fade directly to the sharpest possible
version of the sky, as opposed to a blurred version that is less
suitable for open world fog fading.

Subtle differences may still be noticeable when using a sky material
with nearest-neighbor filtered textures, as it's always sampled
with bilinear filtering.
@clayjohn
Copy link
Member

clayjohn commented Apr 4, 2024

This is an interesting proposal. On the one hand, it allows users to trivially fade objects into the background (albeit in a much more expensive way than just using ALPHA). On the other hand it breaks atmospheric perspective which is a cheap way to simulate sky light scattering through fog. If the far plane just uses the sky value exactly, then it will always appear to do a non-foggy fadeout near the far plane.

@Calinou
Copy link
Member Author

Calinou commented Apr 4, 2024

On the one hand, it allows users to trivially fade objects into the background (albeit in a much more expensive way than just using ALPHA).

I thought this approach would actually be faster, since no objects go through the transparent pipeline. Also, you avoid any transparency sorting issues that would otherwise occur, and you're not locked out from features such as SSR appearing on those materials.

If the far plane just uses the sky value exactly, then it will always appear to do a non-foggy fadeout near the far plane.

I've tested this on master, but while blur is reduced in this situation, it's not using the first mip as I'd expect (and is therefore still blurrier than intended):

PR master
Screenshot_20240328_220355 webp Screenshot_20240404_163727 webp

Fog Depth Begin is set to 20, Fog Depth End is set to 40 and Camera3D's Z Far is set to 40.

@clayjohn
Copy link
Member

clayjohn commented Apr 4, 2024

I've tested this on master, but while blur is reduced in this situation, it's not using the first mip as I'd expect (and is therefore still blurrier than intended):

Maybe blurrier than intended if you are intending this to a fadeout to the sky. Again, aerial perspective simulates the sky light dispersing through fog. It is not a simply a blend with the background.

I have nothing against implementing a feature to allow depth fog to blend to the background sky color, but isn't what aerial perspective does. In my opinion, we shouldn't be removing a feature while adding another. If we are serious about using fog to implement a general purpose blend to sky value for far plane fading, then I think that we should do it in a way that doesn't hijack an existing feature

@akien-mga akien-mga modified the milestones: 4.3, 4.x Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants