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.

  • 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? – Quentin Jul 4 '17 at 20:02
  • 2
    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. – DMGregory Jul 5 '17 at 0:15
  • @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. – Candid Moon Jul 5 '17 at 6:43
  • @wondra yep, this might be not the best approach if it's true, transparency is heavy on performance. – Candid Moon Jul 5 '17 at 6:45
  • 1
    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 – DMGregory Jul 7 '17 at 6:46
up vote 17 down vote accepted

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
    Wow! Cool, thank you for sharing! The game is amazing :) – Candid Moon Jul 5 '17 at 18:11
  • Looks awesome and so simple, tried doing it in my project. Seems to only work using a perspective camera (our game is orthographic). – Jeff Jul 7 '17 at 18:32
  • this is too good to be true haha nice one – Lestat Jun 27 at 0:58
  • 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! – Dawid Aug 1 at 21:00

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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