Page 1 of 2

Progressive Fog Density

Posted: Tue Sep 06, 2016 6:09 am
by Onizuka
Hi,

I need to create a fog material but the actual medium system is not accurate enough for the purpose.
What I need is that the sphere, or the box containing the fog material/medium becomes less delimitate. that the shape of the box disapears completely.
I mean that the density of the fog should be more progressive, like a much less at the entering of the box, and more and more dense as you aproach the center of the box ( no matter its shape), especially on very large scales ( millions or thousands of millions of kilometers ).

I'm not sure if I explain correctly so I I join an image illustrating what I mean: Imagining both spheres are the same diameter, the sphere on the left is more like the actual model of absorption for the fog, and the sphere on the right would be more like what I need.

Is there a parameter or another way to modify this please ?

Re: Progressive Fog Density

Posted: Tue Sep 06, 2016 7:23 am
by Eneen
That could be very useful for ground mist too!

Re: Progressive Fog Density

Posted: Tue Sep 06, 2016 8:35 am
by thesquirell
The shape of the box will disappear, or it would look like it, kinda, with the right settings, if you control scattering with fbm ISL shader.

Code example:

def eval(vec3 pos) vec3 :

let

fracNoise = fbm(pos*30., 8)

in

vec3(if(fracNoise>0.0, fracNoise, 0.0)) * 50.0

Re: Progressive Fog Density

Posted: Tue Sep 06, 2016 11:42 pm
by Onizuka
Thanks Squirell, but since I am completely new with ISL, could you explain me what part of this code is doing what ? and exemples of values that I should change, please ? :)

Edit: Well I get the changes and I'm approaching the results I was looking for thank you man ! But I guess you could still explain more if you want to, so that anyone gets it better :)

Re: Progressive Fog Density

Posted: Wed Sep 07, 2016 2:51 am
by FakeShamus
I've gotten this to work before, for a sphere at least, using a distance (dist) function as in the attached.
the x, y, and z params determine the center of the sphere and the radius is the distance of the falloff. Not sure if this is exactly what you are asking for, but maybe it will help?

you could adapt it to box geometry too, you'd need to combine variations of it for each dimension of your box (x,y,z individually)

Re: Progressive Fog Density

Posted: Wed Sep 07, 2016 3:32 am
by Onizuka
Thank you FakeShamus, it seems interesting for spheres, but It won't work for toric shapes for example or other complicate shapes I guess ( But I still can't make it work for a sphere for the moment :roll: so maybe later )

Re: Progressive Fog Density

Posted: Wed Sep 07, 2016 5:10 am
by thesquirell
Welcome aboard the mysterious ISL train! :D

In essence, you will have to play with number, because I can only describe in words what it looks like when messing with them. The number at the end vec3(if(fracNoise>0.0, fracNoise, 0.0)) * 50.0, that *50 will scale up the values, so what you get is a thicker fog, because of the greater scattering. Numbers inside fbm will define the largest feature and detail ammount. Those will depend on the scale of the volume. My suggestion is to reset them all to 1, and then play further with them. If you want that no edge look, then your scene must be engulfed with scattering volume. If it happens that you find yourself outside this volume, you may easily "bump" into the edges. Sorry I couldn't be more of a help here, ISL is like an Icelandic village to me.

Re: Progressive Fog Density

Posted: Wed Sep 07, 2016 5:21 am
by Onizuka
You're already of a good help; I played with the numbers and got some nice results; of course depending on the scale of my scene the numbers have to be changed to fit the scene.

I understand that the shape of the box containing the scene will better disappear if it englobes the whole scene; but as it is never as simple as that, in the particular case I'm working on, the SSS shape is seen from the outside, that's why I needed a different scattering model than the original.

But I'm approaching what I needed with that code you post TheSquirell, it's a matter of playing with numbers as you said

Edit: Also this code seem great for mist as it allows the fog to be unevenly disposed like volutes of vapour

Re: Progressive Fog Density

Posted: Fri Sep 09, 2016 2:00 am
by Eneen
How to make that with cube to achieve volume fog/mist, denser on the ground?

Re: Progressive Fog Density

Posted: Fri Sep 09, 2016 10:46 am
by Onizuka
Eneen : Try to put the middle of the height of the fog box at the ground level, and adjust its height, and the values to get the result your looking for ?

That's my little test here : By the way if yonosoy comes around, this is officially my first success with visible god rays on a simple render ;)

Re: Progressive Fog Density

Posted: Fri Sep 09, 2016 10:59 am
by arc en ciel
beautiful :o

Re: Progressive Fog Density

Posted: Fri Sep 09, 2016 6:53 pm
by Eneen
Onizuka: wow thanx, I'll try!

Re: Progressive Fog Density

Posted: Fri Sep 09, 2016 8:54 pm
by bubs
Boom! :shock: 8) like this a lot!

Re: Progressive Fog Density

Posted: Thu Sep 15, 2016 9:19 pm
by yonosoy
Congratulations Onizuka and thank you the squirrel, more code to play...

Re: Progressive Fog Density

Posted: Fri Sep 16, 2016 10:58 am
by Onizuka
Thank you guys :)
What do you mean yonosoy ?