MasterK Posted August 6, 2016 Share Posted August 6, 2016 http://www.babylonjs-playground.com/#WCDZS#36 @jerome I want add sps to an item and the item is always rotating. But sps seems doesn't calculate parent's transform in billboard renderMode. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 6, 2016 Share Posted August 6, 2016 why not?http://www.babylonjs-playground.com/#WCDZS#37 best Quote Link to comment Share on other sites More sharing options...
MasterK Posted August 6, 2016 Author Share Posted August 6, 2016 @Nabroski I want item rotate, and sps's position rotate too. But if sps is in billboard. It should always face to camera. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 6, 2016 Share Posted August 6, 2016 @MasterK I don't even understand what is happening with all this Einsteins. witch one should look where? but, anyway, their some build in functions for that, take a lookhttp://www.babylonjs-playground.com/#WCDZS#38 I think jerome will catch up soon Best Quote Link to comment Share on other sites More sharing options...
jerome Posted August 6, 2016 Share Posted August 6, 2016 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. Quote Link to comment Share on other sites More sharing options...
MasterK Posted August 6, 2016 Author Share Posted August 6, 2016 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... Quote Link to comment Share on other sites More sharing options...
jerome Posted August 6, 2016 Share Posted August 6, 2016 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 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 6, 2016 Share Posted August 6, 2016 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 @MasterKhttp://www.babylonjs-playground.com/#WCDZS#41 Quote Link to comment Share on other sites More sharing options...
jerome Posted August 7, 2016 Share Posted August 7, 2016 I have an idea. Not sure this will work though. Quote Link to comment Share on other sites More sharing options...
MasterK Posted August 8, 2016 Author Share Posted August 8, 2016 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 @MasterKhttp://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~ Quote Link to comment Share on other sites More sharing options...
jerome Posted August 8, 2016 Share Posted August 8, 2016 I don't know anything about unity Quote Link to comment Share on other sites More sharing options...
MasterK Posted October 9, 2016 Author Share Posted October 9, 2016 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 9, 2016 Share Posted October 9, 2016 it's still on my todo list, but I just couldn't get the time to code BJS back for now... I wish I can in the next weeks Quote Link to comment Share on other sites More sharing options...
jerome Posted October 10, 2016 Share Posted October 10, 2016 I hope you'll like it : https://github.com/BabylonJS/Babylon.js/pull/1392 the SPS billboarded parented mode works now MasterK 1 Quote Link to comment Share on other sites More sharing options...
MasterK Posted October 11, 2016 Author Share Posted October 11, 2016 does the matrix decompose cost performance? can't just use the worldMatrix transform to vector(0,0,0)? Quote Link to comment Share on other sites More sharing options...
jerome Posted October 11, 2016 Share Posted October 11, 2016 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.