[SOLVED] Shadows for particle system

I am trying to render fire using particle system. This is what i get so far.

Now i want to add shadows to the floor due to fire particles but when I try to use the shadowGenerator, like this

var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
shadowGenerator.useBlurExponentialShadowMap = true;
shadowGenerator.addShadowCaster(firePS);
shadowGenerator.setDarkness(0.5);

it fails giving me this error.

rendererComponent.tsx:378 
TypeError: e.getChildMeshes is not a function
    at e.addShadowCaster (shadowGenerator.ts:740:42)
    at createScene (<anonymous>:77:18)
    at window.initFunction (<anonymous>:97:16)
    at async O._compileAndRunAsync (rendererComponent.tsx:313:17) 'Retrying if possible. If this error persists please notify the team.'

So my question is does the shadow generator work with particle system or its only for meshes?

Shadows only work for meshes. @PatrickRyan any FX tricks you can think of ?

Thanks @sebavan for a prompt response. Never mind I managed to get the fire to look the way I wanted but was hoping to get some shadows but no problem. Here is the live capture from my fire particle system.

2 Likes

This is beautiful !!!

1 Like

@mmmovania, if you want to cast shadows onto your ground plane from any meshes between the fire and ground - say that you encircle the flames with rocks to simulate a campfire - you can simply place a point light in the middle of the particle system and set the rocks mesh as a shadow caster for a ground that receives shadows. Adding an animation to the intensity of the point light and even a little positional animation will make the light appear to be coming from the kinetic nature of the flames.

1 Like

Thanks @PatrickRyan I get the idea.

1 Like