Jump to content

FrameRate dips during Emitter:Pause()


Gonan
 Share

Recommended Posts

I've been messing around with emitters for the last few days, and found what seems to me a couple of strange behaviours.

 

Using the debug Lua build in Leadwerks on steam 3.2.

 

1) FPS drop.

 

If you pause an emitter, either by not starting it, or using

tolua.cast(self.entity,"Emitter"):Pause()

in your Script attached to the Particle Emitter (in the Emitter tab - Play and Loop are unticked) before its completed its full pass of particles, the frame rate drops off, I get 4 to 7 frames per second, with 9999 Particles and Duration 18000.

 

When the particles are playing I get 25 to 30 frames per second.

 

If I let the sequence finish I get 70 to 80 fps.

 

2) I have set up a box, called BigSwitch1, and attached a script, which has a Collision function. Even though I have not begun to play() the emitter, I get certain numbers of collisions reported from the Collision function.

 

These numbers vary depending on the Physics mode and Collision type, I get a fixed number of hits from the non playing emitter.

 

I use this line in the Collision function with in the BigSwitch1.lua script to report the collision.

 

System:Print("Collided with BigSwitch1 was "..entity:GetKeyValue("name"))

 

The Output log shows the hits coming from ParticleEmitter2, which is part of my loaded map.

 

I can get 6 7 or 19 hits reported, these occur as soon as the scene appears on the screen. After that no more collisions are recorded as coming from ParticleEmitter2, but hits from Player do report without problem.

Link to comment
Share on other sites

The framerate drop seems to happen after the last particle that was emitted and no longer processed.

 

The stages are

 

Emitter Playing - frame rate slow but useable.

Emitter Paused - frame rate still similar

no new particles are emitted. frame rate slowly speeds up a bit

if occlusion culling is selected, the frame rate speed up faster as the particles disappear from view under the terrain

after 20 seconds the last particle has long since disappeared and the frame rate is going quite fast by now, but then suddenly dips to very slow.

Link to comment
Share on other sites

I noted that if there was 1 particle, the effect of no particles in use, was not noticeable at all, with 1000 about 50 fps, with 4000 15 fps, and with 6000 12 fps, and 9999 7 fps.

 

So I created two script functions in the emitter script.

 

function Script:OneParticle()--in

tolua.cast(self.entity,"Emitter"):SetParticleCount(1)

end

function Script:MaxParticle()--in

tolua.cast(self.entity,"Emitter"):SetParicleCount(5000)

end

 

Then by using the trigger delay functions with a delay of 5000 set up the flow graph links so that the turning off switch called Pause()function and Activate() for the trigger delay. Output from OnActivate() was then taken to the in for OneParticle().

The delay was required so that particles which had just been emitted had time to fly though the air and disappear through the terrain, without the delay they just vanished mid flight.

 

The turning on switch output was linked to Play() and MaxParticle() as no delay was required.

 

Now the frame rate just slows from 40 fps at the beginning of play() to about 16 during the emission phase, as the last particle disappears it recovers to 60 fps (occlusion culling is set) then climbs to 110 fps.

 

If I hit the pause switch and the emission sequence had finished, I get a 5 second drop in frame rate to 10 fps, then it recovers to 130fps as the particle count is set to 1. Note the emitter is not paused its playing with no visible particles to get this frame rate drop.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...