ParticleSystem and lights / fog

Hi there :slight_smile:

I’m working on an animation where I’m trying to add a ParticleSystem. The particles work fine, however they seem to ignore lights and fog settings in the scene.

Is there any way to have the particles react to lights and fog?

Thanks in advance,

Olaf

I think this might be a repro?

Particle System Examples | Babylon.js Playground (babylonjs.com)

I don’t know much about the particle systems, but I just changed the fog mode in one of the particle system demos from the docs, and interestingly it appears that, when I zoom out, the ground plane vanishes into the fog while the particles do not. @sebavan, is this expected? And, if so, is there a way to change the particle material to one that will be light and/or fog sensitive? I checked the ParticleSystem page in the docs, but the only mention I found of materials was in imageProcessingConfiguration, which I didn’t think was related (though I might be mistaken :slightly_smiling_face:).

1 Like

Lights are not supported by design in the particles and I agree fog could be nice :slight_smile:

If you want a normal material might be better to think about solid particle system and such has all particles are quads so the result won t be that interesting visually.

About fog you should be able to use a custom shader to add it or at least the node material editor: Node Material and Particles | Babylon.js Documentation

I tried but am unfortunately hitting a bug with it so this is a nice catch : https://playground.babylonjs.com/#0K3AQ2#611

@Evgeni_Popov, could you have a look at the issue ? if not I ll have a look ASAP.

In fact it is not a bug: the vertex shader is fixed for particles, you can’t modify it, what you are editing in the NME is the particle fragment shader. The Fog block has a vertex counter part that is missing when creating the particle shader, hence the crash.

Instead, you can implement the fog yourself in the particle shader, it’s not very complicated (I have implemented the EXP fog mode):
https://playground.babylonjs.com/#0K3AQ2#618

Note that I’m using a particle texture (cloud.png) with an alpha channel and I set the blend mode to STANDARD, else you won’t get the effect you want (try changing the blend mode to something else and the texture by another one without an alpha channel like flare.png).

In this case could we remove the fog block from the selection list in NME in particle mode @Evgeni_Popov ? (to prevent the confusion as I was so happy to see it there :slight_smile: )

Here it is:

2 Likes