General Volumetric Fog

@julien-moreau

how would you recommend doing some fast volumetric fog with 6 point lights interacting?

Should I just follow along with: Volumetric lights - Alexandre Pestana and do a loop for each light?

I tired with the Use the Volumetric LightScattering post-process - Babylon.js Documentation but that seemed to make more glitches in my PBR materials than anything.

3 Likes

@Pryme8, an unconventional approach, from the falcon - as usual.

Put a box of frosted glass around the camera?

GREAT random refractions in transluscent 2D Plane experiments recently. Next, attempt is to BOX THE CAMERA… like 2D filters. Just in 3D.

A static box around a cam.

It is imprecise. But might work for “general fog” (and other things).

And you could make certain directions always… more or less foggy.

And change the fog-box based on zone.

:eagle:

: )

why you challenge me :slight_smile:

1 Like

@aFalcon

Ive had a raymarch solution for a while its just not done yet.
https://www.babylonjs-playground.com/#1UWAVK#28

I have not been able to get a raymarched solution working in the manor that I want, I was close at one point I just cant get the “slices” to line up correct and have been struggling getting the depth pass to work as well…

Been getting close but dont have the time to really hammer in on it.

Calling batman (for a friend). : )

Nas starts the concept of “challenges”. So, it is for your joy.

CONCEPTS: for general fog

Do you have a good fog already? Better than Falcons unconventional CAMBOX (no doubt).


@Pryme8 - that RAYMARCH PG is AWESOME (wish I understood it) so diving in.

This was the inspiration of the CAMBOX BTW (THANKS - and perfect starting point).

Also I learn RayMarching from you.


Notion is to INVERT IT - and put the CAM inside… then POS CAMBOX TO CAM.

What would the effect be?? Might it look foggy?

I try as ROOKIE. Looking…

  • flip to inside box not outside

  • decrease alpha

  • add blending (ONEONE or MAXIMIZED)

would it look like (simple) atmospherics?

Trying…

Awwww, dude I did not know :slight_smile: that kinda makes me happy. I might not be the guy to teach you really, but I am glad that I could introduce you to something so interesting.

If you have any questions or confusion on things let me know, I can prolly help with what to look up at least.

1 Like

Got it! The effect works. Your RayMarch GREAT starting point.

Put the CAM in a BOX, invert the culling, drop the alpha, BLEND more, and ANM UV.

This code is really nice… best way to learn shaders (for me). :pray:

Visualizes concept of FOGBOX.

LIKE! : )

Check this out out too, I forgot I added uniforms controls
https://www.babylonjs-playground.com/#1UWAVK#25

You should be able to go “inside” of this box as well.

I also need to get some script in there to pull it out of a death spiral of steps and do a more loose approximation so when you are all up in it the FPS does not drop.

Also, the main hitch is still the plane alignment, I think I have the depth stuff figured out in another demo that I can dig up.

I’m just worried this solution is not performant enough due to the procedural noise, and that I should shift to a volume map.

This is what I am basing it off of:

1 Like

@Pryme8
Unfortunately it is now intended to work with multiple lights at the moment :frowning:
Also, it works only with spot light.
I recommande, for point lights, to adopt a ray marching method but the problem stays the same: you’ll need 6 shadow maps per light and compute Ray marching for each. This require a lot of gpu power. Maybe @Deltakosh or @sebavan have an idea, let’s try :slight_smile:

Not on my side unfortunately.

1 Like

What about a cheap version?
https://www.babylonjs-playground.com/#BHNVUE#2

2 Likes

I might be able to make that work. <3 Its not really want I want but its the best for client considerations.

1 Like

:slight_smile: Those standard particles don’t take light beams… they got no material… no substance. REAL smoke and fog… and dust… can be lit.

But… ohhh… ya need approximately 86 kazillion SPS particles… really tiny ones… to make good LIGHT-ABLE dust-fog-smoke. :slight_smile:

So… yeah, just for fun… I grabbed one of @jerome’s SPS cube-o-particles… bare-bones SPS shapes… 200,000 of them… and shot 4 colored spotlights into it/them.

https://www.babylonjs-playground.com/#2FPT1A#318

Yuh, yuh, yuh. My CPU fan is now heating my entire apartment! :slight_smile: I’m thinking about attaching a popcorn “air popper” to the case vents. It sure is a “pretty” scene… pretty boggy. :slight_smile:

Pryme8 likes them “shafts of light”… the smokey “beams”… we ALL do. Many of us want them… thru stained glass (omg)! Others want the crystal hanging in the sunny window… effect… prisms and rainbow colors.

Well forget that… not a chance, get a clue… 14 post-process render-passes per frame. heh. (Like I have a clue).

All in all, I HAD TO see what a mass of SPS particles… with spotlights shining thru them… looked like. I had to feel the pain… to experience “the grunt”. :smiley:

Maybe SPS needs an “inside of a cone emitter” feature? “Uncle Jerome’s Fake Volumetric Light Beam Machine” - from the makers of SPS. :slight_smile: “It’s an optical occlusion” heh.

2 Likes

That would actually be cool, if not completely useless and impractical. :slight_smile:

Think about shadows. Let’s say we spawn SPS particles within a light-cone area (a spotlight cone/frustum)… and we don’t let them travel outside the light cone… but they can still “boil”-move to some degree (smoke-like).

Now block half the beam with a shadow-caster. (oh no)

Now… the customStartPosition function of the SPS… must NOT spawn particles inside the cone… where the light beam has been blocked. User would see those dark particles… against background colors. If the light cone gets partially/fully blocked by a shadowcaster… the cone-shaped SPS emitter must STOP emitting new particles… in dark-areas of the cone.

Yikes. The SPS customStartPosition func… would need to be in constant radio contact with… um… what? With the shadowGenerator? Geez.

No, me thinks the fake volumetric SPS-based light beams… would NOT ALLOW the light to be used in a shadowGenerator role. Easier. Less brain tumors. It’s a ridiculous idea from the start, eh? 10,000 mesh just for a volumetric light cone? Nah. I’m going to the bar. :slight_smile: