Random particles behavior


photo

Recommended Posts

Hello,

As we upgrade to Unigine 2.13 (from 2.5) we've encountered this problem with the new particles:

Desired behaviour:
- We want to be able to randomly spawn particles on surface of a mesh and then these to spread horizontally along side the mesh triangles.

Simple test case for Unigine 2.13:
- Create a plane
- Create a particles node, attach it as child of the plane
- Select Emitter shape: Random
- Select Direction after emission as between (-1, -1, 0) and (1, 1, 0)

Result:

image.thumb.png.49d760e7af06b4d78843b841b4965331.png

So, while the particles are spawned on the plane surface they are not moving.

Looking over the code I can see their direction over time is cancelled by the direction of the emitter which take the plane normal as its value:

In Particles::spawn_particle:

    if (direction_over_time_modifier->getMode() < ParticleModifier::MODE_CURVE)
    {
        vec3 instant_direction;
        direction_over_time_modifier->getValue(instant_direction, 0.0f, direction_lerp_coef);
        instant_direction.normalizeValid();

        mul(emitter_direction, instant_direction, direction);
        mul3(emitter_direction, emitter_transform, emitter_direction);
    }

direction_over_time_modifier correctly returns random horizontal values but direction is 0, 0, 1 and they are cancelled out.

This spawn_particle is called from spawn_particles:

            mat3 emitter_irotation = inverse(mat3(emitter_transform));
            for (int i = 0; i < num_particles; i++)
            {
                if (world->getRandomPoint(point, normal, velocity))
                {
                    if (length2(velocity) < spawn_threshold * spawn_threshold)
                        continue;

                    mul(direction, emitter_irotation, normal);
                    spawn_particle(offset + Math::itof(i) * inum_particles, ifps, point, direction, velocity);
                }
            }
Where normal is generated as 0, 0, 1 (since we have a horizontal plane here) and this is sent (unmodified in the end) as direction to spawn_particle.

This is Unigine 2.13 is completely different behaviour than 2.5, for which I can obtain this as:

u25.thumb.jpg.30a29f6ca4f8e207ae8ebcf312c12c4b.jpg

Using Direction as 0, 0, 0 and Spread as 1, 1 and the particles move alongside the plane, as intended.

 

So, what is the workaround for this (spawn particles on mesh surfaces and horizontally spread movement) for Unigine 2.13?

 

Kind Regards,
Adrian L.

 

Link to post

Hi Andrian,

Thanks for the detailed description.

This change can be caused by the big particles system upgrade in 2.12. Right now we are trying to reproduce it and get feedback from the dev team. As soon as we get more information we will surely let you know.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to post

Hi and thank you for your support! Any news or ETA on this? Do you have an workaround in mind?

Link to post

And one more question, we are currently stuck with 2.13 for few months while this patch is critical. Do you think you can provide the fix source code and I can try to apply it in old 2.13 source?

Link to post