Reusing particles issue

Problems building or running the engine, queries about how to use features etc.
Post Reply
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Reusing particles issue

Post by kubatp »

Hi,
firstly I need to point out that I still use Ogre 1.7.

I have started with particles and all seems to be good, however there is one thing I cannot figure out.
I am using these two affectors in my particle script:

Code: Select all

affector ColourInterpolator
{
	time0 0
	colour0 1.0 1.0 1.0 0.7
	
	time1 0.1
	colour1 1.0 1.0 1.0 1.0
  
	time2 0.7
	colour2 1.0 1.0 1.0 0.5
  
	time3 1
	colour3 1.0 1.0 1.0 0.0
} 

affector Scaler
{
	rate 0.15
}
It correctly creates particles and gradually changes the alpha from one to zero while making it bigger (it is basically a wake trail behind ship).

The problem is that from time to time (lets say every second or third second) it displays very large particle (while the rest of particles have correct size). Does anyone point me in the right direction why?

Thank you very much.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

I narrowed the problem a bit by changing the ColourInterpolator to this:

Code: Select all

affector ColourInterpolator
{
	time0 0
	colour0 1.0 1.0 1.0 0.0
  
	time1 0.5
	colour1 1.0 1.0 1.0 0.7
  
	time2 1
	colour2 1.0 1.0 1.0 0.0
} 
As you can see it should always start with alpha equals to 0, goes to 0.7 and back to 0.

From testing and looking for the fix, it seems like the problem is in the first frame of the particle lifetime. Basically it displays the particle in a wrong state (wrong scale and alpha value equals to 1 instead of 0). Right after this, is the particle scaled back to initial state and alpha set to 0 as ColourInterpolator.
This is what makes it "blinking", because it shows a big particle with alpha value 1 and it disappears right after (because of the alpha value is changed correctly to 0) and it starts appearing again.

Anyone had similar problems?
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

I was making experiments with this issue and I still haven't found the reason why is this happening. I uploaded a video on youtube, where you can see a boat sailing from one place to another. You can clearly see that some of the newly created particles "blink" and disappear again.

https://youtu.be/6s7B61ft0vM.

To make it even more clear, I attach three images of three following frames.

First frame - everything is ok
Image
Second frame - the problematic particle appears
Image
Third frame - the problematic particle is gone and all is fine again
Image

Please, can somebody tell me what to do or what might be wrong here?

Thank you
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Reusing particles issue

Post by areay »

Hi Kubatp,

What version of 1.7 are you using? I notice this bugfix in the changelog for 1.8

[*]Fixed ParticleSystem's emitted emitters 'sputtering' when emission rate per frame near 1/2.

There could be all sorts of other reasons and undocumented bug fixes that can address this in later versions. I've found that if you're running at a low frame rate or if you're having short freezeups then the PS affectors sometimes use a relatively huge value to scale/interpolate your particles creating weird particles.

A work around might be to change this

Code: Select all

   time0 0
   colour0 1.0 1.0 1.0 0.7
   
   time1 0.1
   colour1 1.0 1.0 1.0 1.0
to

Code: Select all

   time0 0
   colour0 1.0 1.0 1.0 0.0 #set alpha to 0 initially
  
#added this time block
   time1 0.05 
   colour0 1.0 1.0 1.0 0.7
 
   time1 0.1
   colour1 1.0 1.0 1.0 1.0
That means that for the first frame or so the particle completely transparent making this glitch invisible to the player.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

Hi Areay,
firstly thank you for your reply and help. I already thought that noone can help me :)
Secondly, I already tried what you suggested and it didn't help. Just for sure, I attach whole particle system.

Code: Select all

particle_system Wake
{
	material              Wake
	particle_width        3
	particle_height       3
	iteration_interval 0.01
	nonvisible_update_timeout 1
	quota               200
	local_space            false
	common_direction      0 1 0
	billboard_rotation_type vertex
	billboard_type        perpendicular_self
	common_up_vector      0 0 1
	sorted true
      
   emitter Point
   {
		angle               0
		emission_rate		8
		time_to_live		1.5
		direction           0 1 0
		velocity			0.001
		position			0.0 0.32 1.2
    }    

   affector Rotator
   {
		rotation_range_start   90
		rotation_range_end      90
		rotation_speed_range_start 1
		rotation_speed_range_end 1
   }
      
   affector ColourInterpolator
   {
		time0 0
		colour0 1.0 1.0 1.0 0.0

		time1 0.2
		colour1 1.0 1.0 1.0 1.0
		
		time2 0.5
		colour2 1.0 1.0 1.0 0.9
            
		time3 1
		colour3 1.0 1.0 1.0 0.0
   } 

   affector Scaler
   {
		rate 0.15
   }
}
My game is always running with Vsync turned on (60FPS) and the game has never frozen during the movement of the boats....
Is there a way how to find out more about that fix you talk about? I would like to know if this is what is happening or not.

Would you know about another workaround or maybe direction I should go? Basically I cannot leave this issue there, because it is too easy to spot.
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Reusing particles issue

Post by areay »

I just watched the youtube vid, yikes very visible like you say. Can you upload another one but in slower motion and closer up to the boat please? Also, I guess you're letting the PS emitter place the particles and not manually creating them? And do you leave the PS enabled the whole time or are you turning it off and on when the ship changes direction? Also, where is the PS attached w.r.t your ship? In the bow?

It looks like the PS could be reusing particles but not setting the initial conditions correctly. Try increasing the quota to a huge number and see if that helps at all *wildly guessing that this could help*

Here's an interesting frame I grabbed, what's going on there I wonder. Exhausted PS?

Image
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

https://youtu.be/z1K3Ok2hFrY
Here is another video with slow motion and the closest look I can configure now.

Yes, emitter is placing the particles on its own (I do not do that manually). When the ship turns, it dynamically changes the rotation_range_start and rotation_range_end of the affector. The particlesystem is attached to the unit sceneNode (which changes the position in time) to the ZERO position (exactly to the same place as the Boat entity) - the center of the boat Entity is - X and Z are roughly in the middle of the model, Y is the lowest point of the model.

I already tried to increase quota, but it is exactly the same. Moreover these 200 is more than enough, because I was running some tests and there is never more than 20 particles at time.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

Hi Areay,
no other ideas?
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

hmm, last call if anyone has ideas what might be wrong or how to find it out :(
User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ
x 69

Re: Reusing particles issue

Post by areay »

Hi kubatp, I've been away for a while.

The best work-around I can think of is to manually control generation of particles instead of allowing the emitter to do that for you. This will allow you to be sure that the particles you are creating are in the correct place and that they're in the right phase of their lifecycle.

My theory is that your emitter is getting the wrong information w.r.t location, size and colour somehow. If you manually control this you can ensure that everything is where it should be and could also help you with those transitions where your ship's direction has changed abruptly by giving you the change to insert transition particles. A bit of a pain though.

Also, have you looked at updating Ogre from 1.7 to 1.10. It's quite an easy upgrade from the ogre side of things, no idea about what sort of 3rd party integrations or custom changes you've put in though.
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Reusing particles issue

Post by kubatp »

Hi Areay,
thank you for coming back to me and this issue.

I would love to upgrade to higher version, but unfortunately I use MOGRE which is bound to 1.7.4 and it is unlikely that it would be upgraded soon (or ever:))

Anyway I tried to narrow the problem as much as I could and I found few interesting facts:
  • It is not a problem of reusing existing particles, it happens also for newly created ones.
  • I tried to manually change properties once the particle is brand new (when timeToLive = TotalTimeToLive) and fix some of the properties. I also tried to change colour, but it didn't work. It seems that it is overriden by ColourInterpolator. Reseting dimensions also didnt work.
  • The issue is probably in ColourInterpolator.
I was already thinking about rewriting my particle parts and emit the particles manually, but I tried to change the ColourInterpolator to ColourImage (which is basically the same thing) and it WORKED!
For anyone experincing the same problem, try to "rewrite" your affector from ColourInterpolator to ColourImage.

I looked into logs if there have been any changes of ColourInterpolator in 1.8 but it seems like the first change of ColourInterpolator was in 1.9. I am not sure if this issue is in the ColourInterpolator for sure, but it seems so and it was there for a long time.
Post Reply