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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a hard cutoff property to Environment fixed fog (for open world fog fading) #3429

Closed
Tracked by #69579
Calinou opened this issue Oct 14, 2021 · 5 comments
Closed
Tracked by #69579

Comments

@Calinou
Copy link
Member

Calinou commented Oct 14, 2021

Describe the project you are working on

The Godot editor 馃檪

Describe the problem or limitation you are having in your project

The new exponential fog in Godot 4.0 is more physically correct, but it will never completely hide what's in the distance (unless you use a really strong density value).

However, to fade distant areas in an open world game (to hide chunk loading and LOD cutoffs), you need a hard cutoff without having to make fog too strong. Now that we have aerial perspective to better blend distant areas with the sky, we should make sure the new fixed fog is up to the task of open world games.

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

There are two ways to achieve this:

  • Offer a linear/easing curve-based fog option as an alternative to exponential fog.
    • This approach offers more artistic control (similar to what was present in Godot 3.x), but it's more complex to implement.
  • Add a hard cutoff property for exponential fog, which would sharply turn density to 1.0 past a given distance. There are likely ways to make this transition less harsh, but in general, this needs to be tuned along with the density value.
    • This approach is simpler as it doesn't require implementing a whole set of new properties to handle linear fog (such as start and end distances).

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

Add fog_max_distance property to the Environment resource.

This would only be implemented for fixed fog, as volumetric fog is generally not used to hide distant areas completely. (It's still possible to use both fixed fog and volumetric fog at the same time.)

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

No, as fog is implemented in the renderer itself and can't be overridden for all materials at once. godotengine/godot#41415 allows overriding fog on a per-material basis, but this means people would have to use their custom materials everywhere instead of BaseMaterial3D.

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

See above.

@briansemrau
Copy link

briansemrau commented Oct 26, 2021

As noted by @clayjohn in rocketchat, instead of using fog to hide chunks/loading geometry in the distance, the work done in godotengine/godot#54222 should work just as well.

If that PR does in fact address that use case, I believe this proposal can be reduced to just adding different fog modes for artistic control of fog falloff.
That PR does per-instance fading, not per-pixel, which is necessary for smooth fading between larger objects. Disregard :)

@Calinou
Copy link
Member Author

Calinou commented Oct 26, 2021

That PR does per-instance fading, not per-pixel, which is necessary for smooth fading between larger objects. Disregard :)

Indeed, this open world fading needs to be per-pixel in case you have level geometry that spans a large area.

@Calinou
Copy link
Member Author

Calinou commented Nov 11, 2021

@briansemrau What do you think about fading the fog automatically based on the Camera's far clip distance? Depending on the fog density, we can likely figure out a value that looks good relative to the far clip distance by automatically adding some linear fog on top. When fog is enabled, I don't think you ever want to see a sudden far clip cut anyway.

@briansemrau
Copy link

briansemrau commented Nov 11, 2021

What do you think about fading the fog automatically based on the Camera's far clip distance? ... When fog is enabled, I don't think you ever want to see a sudden far clip cut anyway.

I think it's a good solution, but I have a few concerns:

  • What if people want to opt out? I haven't seen this solution implemented anywhere else, so it's hard to say if it's a good general solution without testing.
  • The far plane clips using vertex.z. Fog fades using length(vertex). Enabling fog would limit the view distance in the corners of the screen. I'd consider this an improvement, but it's a limitation in some respect.

I'm curious of the community's opinion of this to see if my concerns have merit.

@akien-mga
Copy link
Member

Implemented/superseded by godotengine/godot#84792.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants