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

Add exponential fog #24596

Closed
Endojo opened this issue Dec 25, 2018 · 7 comments
Closed

Add exponential fog #24596

Endojo opened this issue Dec 25, 2018 · 7 comments

Comments

@Endojo
Copy link

Endojo commented Dec 25, 2018

Godot version:
3.1, commit 10e9221

The current implementation of fog is in my opinion visually not convincing (and I saw other issues stating the same). As the shader code states the fog is a smoothstep between the unfogged color and the color of the fog, based on the distance between the near and far value.

This gives, in combination with the custom depth curve much artistic controll, but is not based on any physical principles.

A more physically plausible result would probably be to use:
fog_amount = 1.0 - exp( -fog_z * fog_density )
where
float fog_z = length(vertex)
without any smoothstep.

To me, the results were much more convincing.
I don't know the theory behind the additional transmission effect for coloring the fog, but using exponential decay there as well produces visually very pleasing results which are at least more plausible even if still not physically correct.

This would replace the fog curves and distances with a single density parameter.

@Chaosus Chaosus added this to the 3.2 milestone Dec 26, 2018
@Chaosus Chaosus changed the title Exponential Fog Change current fog implementation to exponential fog Dec 26, 2018
@Zylann
Copy link
Contributor

Zylann commented Dec 26, 2018

It cannot be just changed, it should be an option instead, because as you said it would prevent some artistic choices, such as having models crossing the far clip to blend with the horizon color.

@Chaosus Chaosus changed the title Change current fog implementation to exponential fog Add exponential fog Dec 26, 2018
@Endojo
Copy link
Author

Endojo commented Dec 26, 2018

Maybe it would be a solution to rename the current implementation to something like "fade to background" and add exponential fog as a physical based solution.

Probably the strength of spot or point lights should decrease with the distance too, as their emitted light gets absorbed from the fog in the same way.

@Zylann
Copy link
Contributor

Zylann commented Dec 26, 2018

If we rename or change anything it would break compatibility so it would be something for 4.0 in this case.

@Chaosus
Copy link
Member

Chaosus commented Dec 26, 2018

If it will be an option it would not break compatibility

@reduz
Copy link
Member

reduz commented Dec 26, 2018

Fade to background (skybox) is not easy to implement for now because it requires a texture unit and there are too many of them in use already. With Vulkan port it should be easy to add, as it can be bindless.

@Zylann
Copy link
Contributor

Zylann commented Dec 26, 2018

@reduz I was mostly mentionning that because it's possible to approximate it, as skyboxes can have a relatively uniform horizon.

@Chaosus Chaosus modified the milestones: 3.2, 4.0 Jan 7, 2019
giarve added a commit to giarve/godot that referenced this issue Mar 14, 2020
Introduces a new parameter, exponential fog density, which allows a default for exponential fog while preserving fog's alpha color channel to specify fog density.

The commit also adds missing hide_prefixes[] for height and depth fog properties.

Requires godotengine#36989.

Should fix godotengine#24596.
@clayjohn
Copy link
Member

Added in #41240

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.

5 participants