Screenshot and ParticleSystem

It seems that the CreateScreenshotUsingRenderTarget function stop working with ParticleSystem if the emitter is only a vector.

See line 28-29:

I think that whatever the emitter is, you won’t see the particles in a screenshot by using CreateScreenshotUsingRenderTarget.

After some source digging, it seems RenderTargetTexture deals only with meshes: the _renderList property used internally to render objects in the texture is an Array<AbstractMesh>, and particle systems are not AbstrachMesh: the list of objects is retrieved through a call to Scene.getActiveMeshes() whereas particle systems are found in Scene.particleSystems[].

Don’t know if it’s a bug or if it is expected… Looks like a bug to me, however. Maybe @Deltakosh will have some insight about this?

You should use CreateScreenshot instead, which will work as expected.

Unfortunately, @Deltakosh is out for the next week. @sebavan, does this sound like a bug to you?

As @Evgeni_Popov mentioned this is not a bug but the expected behavior.
This is why we also have CreateScreenshot function


Other option is just to create a dummy mesh and use it instead of a vector3 so you can add it to the render list of the rendertarget

Ok thank you.

Yep I noticed I could make it work with a dummy Mesh as you can see in the playground.
I just also expect it to work with a simple Vector3 that is why I wanted to tell you about the issue.

But if this is expected then it is all good! :wink:

About that I recently tried to improve our scene performance in our tool Naker.Back
In those scenes, there is only one static sphere and one ParticleSystem
Despite that evaluateActiveMeshes function still count for 15% of the scripting time.

This test is made with a lot of optimization on the only sphere present like
mesh.doNotSyncBoundingInfo = true;

Plus if I do this.scene.freezeActiveMeshes();, the Particles stop moving.

So I wonder why I have still that much scripting time with evaluateActiveMeshes if this not used by ParticleSystem?
If you could explain to me why or lead to a solution to avoid that, it would be awesome! :wink:


Well it is 15% of a big one? Because if a frame is just 5ms then 15% of it is negligible

Can you show the length of a frame?

The scripting time represent 10% of my test time.

And from the log in chrome, the frame is in average around 2ms?

Note that what you quoted is related to what the render method of TextureRenderTarget is doing.

When rendering a scene, _evaluateActiveMeshes is called at each frame (inside _renderForCamera).

I think it’s expected that you spend most of your time in this function in your case because it’s where the particle system is updated: the function ParticleSystem.animate is called inside _evaluateActiveMeshes.

1 Like

Ok thanks for the explanation @Evgeni_Popov!

This is clear now! :+1:

No need to worry about _evaluateActiveMeshes :call_me_hand:

1 Like