I’ve been messing about with the panda particles, it has some flaws, but it is actually better then I expected.
The particle panel is a very bad authoring tool in my opinion, but I’m already working on something easier to work with (and as an added bonus a save/load system that doesn’t use ‘exec’ to load ).
I’ve written a shader that changes the texture, size and color of a particle based on the vertex color of that particle, and I’ve setup the particles system in such a way to change the color of the particle from black to white with the particle life - in other words I can change the texture, size and color of a particle over its life. The original system only allows you to have one size when the particle is spawn and another when it dies - its size changes from one to the other, you couldn’t have a particle that starts small, grows big and then shrinks again to a smaller size. But I’d like to have even more control.
Is there a way I could write different properties of a particle (mass, velocity, initial angle) into different vertex color channels (or custom vertex attributes)? Or some clever way to get this values somehow in a shader?
Yes. Just create a new vertex column holding the information you want. You can access it by declaring an input vector in the shader with the same type, size, and name, ie.
in vec3 something;
fetches whatever data is available for a vertex in a vertex column called “something”.
In 1.9, integer vectors (ivec, uvec) are also supported if you don’t want normalized data.
That’s the easy part, I know how to do that with a GeomVertexWriter/GeomVertexRewriter, or at least I think I know how to
But how do I get the particle system to write a custom vertex column for me?
If I have to rewrite the system in python, then I suspect that updating each particle position (or pulling the data I wanted in the first place from the physic engine just to push it to a shader) will be a bit slow.
It would be simple if the particle system would allow to change the color of a particle not only based on his ‘time to live’ but also based on its velocity and/or mass.
PointParticleRenderer has a PointParticleBlendType named PPBLENDVEL and I think ‘VEL’ is for velocity here, but I don’t see it changing the color of particles and I want to use SpriteParticleRenderer anyway, so that’s no help.
My goal was to make fire-like effects using just one system.
If I set the system to spawn particles with a variable initial speed, life and mass, and add some forces then I get some particles that are slow and go high (smoke), some that move fast and die fast near the emitter (flames) and some that shoot to the sides and fall down (sparks), but I have no way to give them different colors/textures.
Hmm… I’m not really familiar with these elements of Panda, so my thoughts may not be at all useful, but in case they are:
Could you perhaps have a single custom vertex column that specifies which other custom values should be present? For example, the bits of the x-value might be flags that specify whether mass is used to determine the texture, whether velocity is used to determine life-span, and so on.
So the question is whether it is possible to get the particle system to write things like age, lifespan, velocity, mass, etc. to vertex columns?
That wouldn’t be too difficult to add. I don’t think I’ll have time for this in the short term, but which things do you need, and which particle renderer are you using?
I think it’s too late to add this to the 1.9, but it can be (one of) the first item on the 1.9.1 wish list
I’m using the SpriteParticleRenderer, and I’m mostly interested in the particle initial mass and velocity (‘amplitude’) if the current age (time passed since the particle spawned) and lifespan would be available, then I’d have all I need without color hacks, and that makes 4 values to nicely pack into one 4 value vertex attribute.
A ‘life’ parameter where 0.0 is the particle birth and 1.0 is it’s death (age/lifespan) could also be ok, if that’s simpler to add then age and lifespan as separate values.
I think some interesting effects could be made based on the current speed or direction of movement, but I can’t say I have a specific use for that.