Rain effect causes screenshots to fail?

See this demo:

https://playground.babylonjs.com/#1S4RQG#1

Look around with the mouse and notice a bunch of screenshots being generated in the sky are blank.

Took me a couple of hours to figure out the rain effect was the cause in my game. What’s going on here?

The rain particle system is creating/deleting a lot of sub particle systems / nodes and for some reasons it interferes with the screenshot…

I didn’t find another way than pausing the particle systems (meaning, stop calling the animate function) just before taking the screenshot and unpausing them just after:

https://playground.babylonjs.com/#1S4RQG#27

Interesting. I noticed toggling this.scene.particlesEnabled in the same way also works. Both ways remove the rain from the screenshot (maybe the rain is never in the screenshot?)

This looks like a big to me…

The rain is not in the screenshot because of the way the particle systems are handled in the render target texture. See this thread for more info: Screenshot and ParticleSystem - #2 by Evgeni_Popov

To sum up: if a particle system has no emitter or has an emitter which is not an AbstractMesh, the particle system is not rendered in the texture.

In fact, the emitter does not have to be an AbstractMesh but it mush have a position property and a isEnabled() method. Also, this emitter must be in the list of the visible meshes of the frame.

So, you have a way to make the rain visible in the screenshot: set a dummy value to the emitter property to all the particle systems before taking the screenshot and reset back this property after:

https://playground.babylonjs.com/#1S4RQG#31

2 Likes