Recently, I have been looking for techniques to make volumetric fog on some Y position level of the game world. But all I have found are some fog made by using particle system or built-in engine fog that doesn't really fit what I'm looking for.

In my case, I need a fog that is both efficient and dense. It should be all over the gameworld, but obviously, for performance reasons, it can be rendered only as a part of a camera or shader and look like it's moving though it's just an illusion. I could set a particle system if it's the best choice, attach it to the camera and make it move.

So the main question still stays - how can I implement a volumetric fog that is both dense and performs efficiently?

As a particular engine I'm using, it's Unity.

As an example what I mean, here is the link to a game with the effect I'm looking for: Astromike

Example screenshot from a game using a dense height-based fog.

  • \$\begingroup\$ Bit of a GLSL noob here, but what about tinting the pixels in the fragment shader, based on their Y coordinate that you'd retrieve from the vertex shader? \$\endgroup\$ – Quentin Jul 4 '17 at 20:02
  • 2
    \$\begingroup\$ Have you reviewed the Unity talk on "Special Effects with Depth"? While it's several years old now, the principles still apply. They cover both height-based fog and "fluffy fog" that pools in empty spaces and thins around obstacles, and since all the examples are Unity it should be easy to apply. \$\endgroup\$ – DMGregory Jul 5 '17 at 0:15
  • \$\begingroup\$ @Quentin yeah, good idea, though is it going to be shader per object right? Then it would require changing a lot of shaders. I'm a noob in shader programming too, so I might have written some nonsense. But as far as I know, vertex shaders apply to objects. And coloring might not give movement effect. I understand that if I want movement every little thing that moves inside should be an object, so particle system might be the best way to go. \$\endgroup\$ – Candid Moon _Max_ Jul 5 '17 at 6:43
  • \$\begingroup\$ @wondra yep, this might be not the best approach if it's true, transparency is heavy on performance. \$\endgroup\$ – Candid Moon _Max_ Jul 5 '17 at 6:45
  • 1
    \$\begingroup\$ Lists aren't a good fit for our Q&A format either, because when is a list complete? How many "different situations" are enough? By what metrics do we judge "best"? Generally this format does best with clearly focused questions with answers you can validate. So if you feel you have an answer that fits your needs, it's actually better to edit your question to narrow it to what you actually needed in the first place, rather than leave it overly broad and incompletely answered. Other users can always ask other questions specific to other aspects, getting more focused answers relevant to their case \$\endgroup\$ – DMGregory Jul 7 '17 at 6:46

I'm the creator of Astromike. :)

Actually, I'm using a pretty simple trick to make it look like fog. I'm developing Astromike using Unity, so if you use Unity, you can do the same. But I assume you can also recreate the same shader for other engines.

What I do is, I set up a plane for the fog, and add a material with Particle / Alpha Blended with a Soft Particle Factor (0.32 in my case) shader on. That's it.

Fog plane: http://imgur.com/a/MAEFW

Settings: http://imgur.com/NJVAaIQ

It works for me due to the camera angle and might not work for other people.

The rest is just post-effect stack ( Bloom, Vignette, etc.. ) Hope this helps. Cheers.

  • 1
    \$\begingroup\$ Wow! Cool, thank you for sharing! The game is amazing :) \$\endgroup\$ – Candid Moon _Max_ Jul 5 '17 at 18:11
  • \$\begingroup\$ Looks awesome and so simple, tried doing it in my project. Seems to only work using a perspective camera (our game is orthographic). \$\endgroup\$ – Jeff Jul 7 '17 at 18:32
  • \$\begingroup\$ this is too good to be true haha nice one \$\endgroup\$ – Lestat Jun 27 '18 at 0:58
  • \$\begingroup\$ Hi @Mikea15, very nice looking game! Unfortunately, I fail to recreate the effect you mentioned -- I added Bloom to the post processing stack, however it spreads on objects even if the fog plane is behind them (not surprisingly), while in your demo it seems that vertical edges of the columns are clean of the bloom effect. Also, in my Soft Particle Factor does not change anything, regardless of the value. It would be great if you could provide a small demo scene that would show this. Thanks! \$\endgroup\$ – Dawid Aug 1 '18 at 21:00
  • \$\begingroup\$ @Dawid i know this is late but you need to set your camera rendering path to deferred and make sure soft particles is checked on quality in project settings \$\endgroup\$ – Rito Ramos Aug 2 '19 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.