Jump to content

Solid Particle System billboard not right while parent rotate


MasterK
 Share

Recommended Posts

Ok, I don't know much about mesh parenting, but I suppose the children position is then expressed in the parent local system, that's why the billboard doesn't work here.

Does the billboard works fine in the same case with the standard particle system ? no idea (I guess yes, because it's not rotated but drawn direcly ever in the clipped space).

I'll check this... and need to think if it's worth changing it regarding the perf. If you use nly planar particles in billboard mode, the standard particle system is probably better fitted than the SPS.

 

[EDIT] from this :  http://doc.babylonjs.com/tutorials/Position,_Rotation,_Scaling

I understand that the parent rotation has priority over the child rotation. Billboarding is just rotating the particles according to the SPS mesh rotation (and the cam position) what is zero because only its parent is rotated.

 

Quote

Basically in simple terms, don't rotate or move a child until after you've assigned it to the parent, and keep in mind that additional rotations will be in relation to the parent after the parent rotations are applied to the child.

 

Link to comment
Share on other sites

18 minutes ago, jerome said:

Ok, I don't know much about mesh parenting, but I suppose the children position is then expressed in the parent local system, that's why the billboard doesn't work here.

Does the billboard works fine in the same case with the standard particle system ? no idea (I guess yes, because it's not rotated but drawn direcly ever in the clipped space).

I'll check this... and need to think if it's worth changing it regarding the perf. If you use nly planar particles in billboard mode, the standard particle system is probably better fitted than the SPS.

@Nabroski billboard~ the plane is alway parallel with screen~~

@jerome

I need to use sps, I need to make particleSystem in babylon like unity3d.

 

As you said, if always planner particles, standard particle system is better.

So use SPS will sparely use billboard.

So make billboard right(even lost perf) will not lost SPS's perf~~

Am i right?

 

And i think billboard method is not very perfect, because when i rotate camera, the billboard will rotate by z, and it looks not stable...

 

Link to comment
Share on other sites

Actually what is done to compute the SPS billboard : https://github.com/BabylonJS/Babylon.js/blob/master/src/Particles/babylon.solidParticleSystem.ts#L509

The SPS mesh rotation is taken in account to compute a fake camer position by un-rotating it for the current mesh rotation value. This needs to compute an inverse rotation matrix.

We can't decently compute a inverse rotation matrix per particle (imagine 10K particles would mean 10K inverse rotation matrix computation CPU side each frame !), so only one is computed for the whole SPS mesh from its rotation, what is an acceptable approximation if the particles aren't to far from the SPS mesh local origin or if they are centered or symetric around this origin, what is usually the case. I need to check if taking in account all hypothetical SPS mesh parent tree is worth it regarding the performance in order to compute the related inverse rotation matrices... and how this could be done (not sure yet).

Anyway, the SPS billboard mode is not as efficient as the standard particle one.

It can't be by design. 

It's just an easy way to rotate at once all the particles, solid or planar, in front of the camera looking direction, say, just a tool with its convinience and weakness, so that the user doesn't need to implement it by himself. All the SPS rendering under the hood is just the classical BJS mesh rendering, so with the benefit of alpha blending, transparency, z-ordering, etc.

As you understood, the SPS general performance is not affected when the billboard mode isn't used. The billboard mode only implies this extra inverse rotation computation (and then the fake camera position). Adding the mesh parent management will add more computations in the billboard mode only.

The standard particle system is better in this very case (planar particles ever facing the cam) because the particles are drawn directly in the clipped space... so as they would have only 2 coordinates to simplify (you can't rotate them on Y nor X axis). The same for the sprite manager what uses the same principle.

In brief, if you need billboarding 2D planar particles, unless the SPS fit your need by default, I would recommend to use the standard particle system.

If your particles have any 3D features (solid or planar but rotated along X or Y), whatever they need to be billboarded or not, then the SPS should be your friend ;)

Link to comment
Share on other sites

On 2016/8/7 at 6:25 AM, Nabroski said:

I still don't understand the problem, you want to disable that the Einsteins move with the camera ?
billboard~ the plane is alway parallel with screen~~  why using billboard then ?
you need a const vector or something

@MasterK
http://www.babylonjs-playground.com/#WCDZS#41

@Nabroskiit means particle displayed as a 2D UI~ 

in unity there's  5 renderMode:

billboard, (normal face to cam)

stretched billboard (make sprite long by its speed, I stuck here)

horizontal billboard

vertical billboard

Mesh.

17 hours ago, jerome said:

I have an idea. Not sure this will work though.

@jerome

Good and do it~~

Can i ask more? can you realize the 4 renderMode above in unity? That's my ultimate expection~:wub:

Link to comment
Share on other sites

  • 2 months later...
On 2016/8/7 at 4:39 PM, jerome said:

I have an idea. Not sure this will work though.

Where is your idea @jerome

I must use sps. because the particle system has hiberarchy. 

one sps.mesh would be another's parent. i can't just use standard particle instead of sps.

and the parent rotation problem still need to be fix. I hope you can help me...

caculate the sps.mesh's absolute rotation to let the billboard mode right.

Link to comment
Share on other sites

For a given mesh, its world matrix is computed once per frame. This computation takes in account some extra constraints, like the mesh parenting for instance to set rotation or position values according to these dependencies (parents). So my idea was to NOT recompute by another way the parent dependencies for the SPS but to re-use the computation done while calculating the its mesh worldmatrix.

The decompose() function is really simple as it doesn't compute much stuff but just extracts the rotation matrix (and the scale value + translation vector) from the pre-computed world matrix. In terms of computation, it's just 12 float operations, done once per frame. So it's nothing in terms of performance.

 

As you can see, your initial PG is now fixed : http://www.babylonjs-playground.com/#WCDZS#36

the Einstein images keep facing the camera

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...