0
$\begingroup$

I have a simple question just because I can’t find any good example in the internet. How to create fog without using particles? How to make for with different density on different locations and in general how to make gaseous objects (like a nebula)? Any pointers? Thanks for reading

$\endgroup$
2
  • $\begingroup$ You use Raymarching. $\endgroup$
    – joojaa
    Oct 21, 2021 at 16:18
  • $\begingroup$ @joojaa On a screen quad? $\endgroup$
    – Mike F
    Oct 21, 2021 at 16:24

1 Answer 1

0
$\begingroup$

Clouds are a good fit for this but good quality cloud(s) rendering isn't usually simple. Searching for cloud rendering should give a few hits good hits. Here is neat shader toy rendering a cloud like tunnel. But take a look at your GPU stats, ray marched clouds can be very expensive. If you search shader toy for clouds you'll find several really good examples. Search shader toy for nebula as well. Sometimes the effects on shader toy can be adapted to rasterization.

Atmospheric shadowing/Volumetric lights/many other names... can be extended by sending a ray through a 3D volume to accumulate fog along that ray, combined with flow fields these techniques can create outstanding effects but it is fairly difficult to implement. (each texel of the 3D volume tends to represent large areas and aliasing becomes an important issue that has to be dealt with)

Next, it is possible to combine multiple effects such as halo's, planar fog, etc., to get an effect for particular scenarios.

If the "nebula" is always off in the distance (cannot be approached) then a simple quad with a partially transparent texture mapped to it can provide a nice effect.

There are dozens of other approach's I listed some of the most current.

Edit: Searching for "volumetric fog" gives a lot of hits. This presentation by Wronski for siggraph 2014 is very good. Wronski has a blog that is generally pretty good to read. Techniques like this work best when all the buffers that are needed to create the effect are used by as many techniques as possible because it amortizes the cost of creating them. Cascade shadow maps in particular go with this technique well.

Here is a link to a fairly straight forward approach to generating volumetric fog. It has shaders included but is light on the math/explanation.

$\endgroup$
2
  • $\begingroup$ Thank you so much for the detailed answer. I am searching this a long time now and the only thing I have achieved is adapting shadertoy examples to quads, but I don't know in opengl how to make them take 3D space so that you can approach them and fly through them. As for the volumetric fog I've seen presentations using 3D textures which I don't understand (GPU pro6 - chapter 3)... My problem is how to render volume fog in 3D space and not in a quad with a shader? $\endgroup$
    – Mike F
    Oct 22, 2021 at 7:45
  • $\begingroup$ I added an edit with a couple links that might be of help. $\endgroup$
    – pmw1234
    Oct 22, 2021 at 12:27

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.