On Wed, Dec 25, 2013 at 2:20 PM, Qasim Khalil <[email protected]> wrote:

> (Using latest revision 1271.)
>
> The code for particle system seems to suggest that each individual
> particle can have its own size:
>
>    1. The *size_var* variable
>    2. *self.particle_size* array on line 208 in *particle.py* (whichi is
>    only referred to in one other location) which uses *size_var*
>
> However this is clearly not being used. The size is decided by the
> function *get_scaled_particle_size *which does not use *size_var.*
>
> But the real question is, what is the behaviour supposed to be?
>

Looking from current implementation, it is 'one size for all particles'

Looking to openGL point sprites capabilities when not using shaders, the
only (openGL) supported modulation of particle sizes is through
 GL_POINT_DISTANCE_ATTENUATION , which changes size from the z-coord. I
would think is not a god fit for cocos.

The alternative codepath for particles in cocos draws quads, so it can be
extended with a per-particle size.

A modern approach would be to use shaders.


>    1. Individual particles have their own size (with parameter *size_var*)
>    which do not change once the particle has been created.
>
> As indicated above, the point sprite codepath does not support this and
probably don't worth to implement in a hackish way using perpective
The quad codepath can easily support individual sizes, and dinamic sizes,
with certain performance loss. It is probably worth to implement and
benchmark.


>
>    1. The entire particle system has a fixed size decided by *size *and 
> *size_var
>    *from the very beginning.
>
>
This is the actual behavior.

>
>    1. The entire particle system has the size change randomly using
>    *size_var* somehow.
>
>
I'm not sure what is intended here. Breaking the array of particles in
subsections of different sizes ?

> The second option is quite redundent - the user would just set a random
> size at the start by himself. The third option is easy enough to implement
> but is just weird. So I believe the first option is the correct behaviour.
>
> From the code the drawing seems to be done with the single line 
> *glDrawArrays(GL_POINTS,
> 0, self.total_particles)* (line 290) and the point size is set on line
> 257 before that. So, I'm not sure if you can draw differently sized
> particles efficiently.
>


 To play with different sizes in a particle system, I would say:

Using a variation of the quad render should be easy to implement and would
have support on any system that supports openGL at all.

An implementation using shaders would be interesting, but it will take some
time to write, especially if you are not familiar with shaders.

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to