-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Control fog (both simple and volumetric) from shaders #2643
Comments
Duplicate of #2261? |
Fog is calculated during the regular drawing off meshes, not in its own pass. For simple fog, we exposed the ability to override it in spatial shaders godotengine/godot#41415 For volumetric fog we have #2261 |
Ah hmm Would it be possible to add a global override for it? |
Unfortunately, this likely isn't possible for various reasons: #2595 You can convert a SpatialMaterial to a ShaderMaterial, but there isn't an easy way of making sure it's used everywhere right now. @clayjohn Do you think a way to override SpatialMaterial could be exposed, in the same way the MainLoop can be overridden (for instance)? I suppose this would cause issues with the editor though, since gizmos assume that they have access to a "vanilla" SpatialMaterial (StandardMaterial3D in |
Hmm I do think it would be nice to have some way to add features to the default spatial/shadermaterial. Should I make a proposal for that instead and close this one? |
I wouldn't do it just now, because we don't know if this proposal (the one you've just posted) is technically feasible yet. |
Right now, no. In theory we could:
I don't think any of these options actually solve your problem. It sounds like you are looking for a way to implement proper atmospheric scattering which is not the same thing as fog. In my opinion atmospheric scattering is a feature in its own right and should not be bundled in with fog.
No need to open a proposal for that, just add your additional thoughts to the already open proposal #1779 |
For the record, I made a proposal for this: #1698 |
Ah, not quite. Atmospheric scattering refers to the scattering that makes the sky blue and distant objects fade towards white/blue. |
Yeah Adding a feature just for doing atmospheres like this would be a bit too specific, so that's why I made this proposal, as the normal distance fog seems to work a lot better for how I want the atmosphere to work, and it could be useful to other users as well for making custom fog effects. |
This is now implemented for volumetric fog using FogVolume nodes, which can be local to an area or global: godotengine/godot#53353 Fixed (non-volumetric) fog does not have a way to be overridden globally yet. There are however several proposals on improving fixed fog to make it more usable, such as #3429 and #4102. Fog can also be added on a per-material basis already with the |
Describe the project you are working on
A flight sim
Describe the problem or limitation you are having in your project
It's hard to properly get my custom atmosphere shader to interact with objects the way I want to
Describe the feature / enhancement and how it helps to overcome the problem or limitation
As of now Godot 4.0 supports both volumetric fog and a simpler constant density fog model. Both of these can't really be controlled from shaders, besides the simpler fog which can take on the color of the sky to sort of simulate the atmosphere
My proposal is: Allow either the simple fog or the volumetric fog to be controlled from shaders, to help with these kinds of effects
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
The Fog and Volumetric Fog sections in WorldEnviroment will be changed to accept a Fog or VolumetricFog Resource instead of most of their current parameters. These resources work similar to Materials, with one subclass being the standard controls that are currently implemented, and one subclass that allows a shader, like ShaderMaterials
For regular Fog, the shader would take in the scene color, background color, scene depth, sun direction, camera position and camera ray direction, and as output it would output the new scene color, or something similar.
For volumetric fog, the shader would allow changing the volume density and color of the fog at different locations, but I don't really know how this would work best with how the volumetric fog is implemented.
If this enhancement will not be used often, can it be worked around with a few lines of script?
As for the simplified fog, it's possible with custom post processing, but it's quite hard to get that to look correct, and also still work with the background color. Transparent materials also don't work very well together with this approach.
Is there a reason why this should be core and not an add-on in the asset library?
It changes part of the rendering behavior, which can only be done via core
The text was updated successfully, but these errors were encountered: