Proper Atmospheric Fog

Hi all, a fairly direct and simple question, using all the fog modes provides more or less results that look like this in panda3d:

This has always puzzled me, since it doesn’t look like the fog you’d see in games, even old games from the ps2 era:

standard fog

Panda’s fog appears to be attached to the geometry, whereas fog from other games is suspended in the atmosphere and extends to cover the geometry as well. Are such effects achieved only via shaders? Or are there other tricks like adding dummy-nodepaths with transparent-geometry at different points in the scene to make it seem as though the fog is suspended in the atmosphere as well? Any pointers on how to achieve a fog-effect like in the second image will be greatly appreciated.

Thanks in advance.

I can’t say for certain, but silent hill 2’s fog is probably very similar to panda3d’s fog.
Did you set the background color to match the fog’s color?

Nevertheless, I strongly suspect that the fog in those games worked in much the same way.

I suspect that the discrepancy is as Jackson_Sutherland suggests, above: those old games simply set the clear-colour to match the fog-colour, thus producing the illusion of a continuous, airborne fog.

Note that you are comparing a flat scene with a deep one. If you add details, you will get something similar. And the second point, the shader-terrain example has a fog built into the shader.

Perhaps you mean this.

Something similar can be found in RenderPipeline, but it has not been supported for a long time.

Here is an example of fog, there is no lighting here, so it looks flat. I think that you can somehow add noise to the buffer for fog, but the filter manager is not used here, I have no idea how to do it.

fog = Fog("fog")
fog.set_color(128/255.0, 128/255.0, 128/255.0)

Thank you both for the insight; yes, I did make set the background colour to match the fog’s colour, however, the results were at times not satisfactory when camera movement came into play. However, if these games did the same thing that panda3d does when it comes to basic fog as you suggest, then I will have to go with something similar, albeit with some hacks to accommodate sudden camera transitions.

Could you elaborate, please? Perhaps whatever issue you’re seeing might be at least alleviated somehow.

Oh, and let me note that old games may at times have added particle systems (or something similar) into their fog effects, using big, semi-transparent particles to provide a bit more depth and form to the result.

Yes, something like volumetric fog sounds interesting, but I’m not sure if in my case it would warrant all that effort, since I’m trying to keep things more or less simple. Further, I’m not predisposed to using the render pipeline, a marvelous tool no doubt, but with the drawback of crashing on certain cards (I think intel cards?), that and it being somewhat bulky.

I do get similar results to that, but at times the edges of my world pop-out, which is what prompted me to start this thread. I’m not sure what adding noise to the fog buffer would achieve, an example of that in action would be nice though.

Sure, but I doubt it’s that big an issue, I probably just have to modify the settings like the linear-range/fall-back for the linear fog or the density for the exponential fog up when the camera shifts to a point in the game that isn’t done generating yet, but if something else happens to be the matter then I’ll ask if necessary.

Ah, fair enough. I think that I can imagine the issue that you’re seeing, and how you deal with it likely depends on the specifics of your game and how the issue presents for you. There are, I daresay, a few ways of addressing it!

I added lighting, but it still looks simple.


It will: it’s a simple technique.

As I said above, I think that some older games mixed in large-scale particle effects to add some depth and texture to their fog.

I think I remembered that I did something similar.

However, I didn’t adjust the lighting. By the way, the fog can be made more interesting if you make a ball with a transparent texture around the player, in the video blue is an imitation of a force field, but you can make a good background that will merge with the fog.


Alternatively, you can use AmbientOcclusion. This will add silhouettes to your objects. I think it would also be correct to use the linear fog mode, it had more options for control.

Sorry to resurrect this a month later, but I was wondering how you combined the fog with lights, do you mind posting some sample code of what you did? The appearance of the fog is modified by the presence of ambient light, direct light etc. I was wondering whether one could force the fog to retain the appearance it has on the scene models in the absence of any light.

I do not know how soon I will be near the computer, what to tell you about the code. As for lighting without light sources, then you can just bake the lighting map and set the mixing type to multiplication.

Thanks, but I’d like to avoid using any relatively advanced shader or additional maps of any kind, I’ve found a workaround however, to use linear-fog, set its linear range very low and parent it to the camera, then position it further in to hide the edges of ungenerated terrain. It turned out to be quite easy to do in the end.