jerome Posted October 18, 2016 Share Posted October 18, 2016 here's a PG example : http://www.babylonjs-playground.com/#10RCC9 There's no physics engine here, just a simple implementation of bouncing against a sphere : resultVelocity = -incomingVelocity + 2 * dot(normal, incomingVelocity) * normal As you can see, 200 solid particles (boxes) are emitted from some kind of fountain with an initial velocity and fall down to the ground because of the gravity. A slowly moving sphere waves in the air and the particles bounce against its surface. When they hit the sphere, they change slightly their color and are applied some energy loss. This PG runs also at 60 fps in Chrome here with 5000 boxes ! http://www.babylonjs-playground.com/#10RCC9#1 Wingnut, dbawel and adam 3 Quote Link to comment Share on other sites More sharing options...
adam Posted October 18, 2016 Share Posted October 18, 2016 Here is SPS working with OIMO (unplugged): 200 boxes: http://www.babylonjs-playground.com/#12SEYV#0 600 boxes: http://www.babylonjs-playground.com/#12SEYV#1 1200 boxes: http://www.babylonjs-playground.com/#12SEYV#2 1200 spheres (Captain Kangaroo test): http://www.babylonjs-playground.com/#12SEYV#4 1000 spheres and faster gravity: http://www.babylonjs-playground.com/#12SEYV#5 http://www.babylonjs-playground.com/#12SEYV#6 http://www.babylonjs-playground.com/#12SEYV#8 JackFalcon, jerome, iiceman and 1 other 4 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 18, 2016 Share Posted October 18, 2016 (Wingy wears-out a mouse from so much bookmarking) You guys are pretty close to basic fluid-dynamics, as is Raanan's cloth demo. hmm. Jerome, yours is not doing particle-to-particle collision, right? Particle-to-particle collision (p2pc) would take lots more computing horsepower, I would suspect. And then... into a tube they go. Hydraulics Sim version 1.0! Yeah! Nice demos, you guys. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 18, 2016 Share Posted October 18, 2016 Oimojs is better than my implementation because it checks also collisions between particles (what I don't do, I just check against the sphere) and needs less user code, but the framerate is also a bit lower then. ([EDIT] oimo hardly works here with 5000 boxes) Really nice demo @adam , just what @dbawel was asking for in the first post, I suppose Quote Link to comment Share on other sites More sharing options...
jerome Posted October 18, 2016 Share Posted October 18, 2016 I can't stop playing : http://www.babylonjs-playground.com/#10RCC9#2 (tetrahedrons) http://www.babylonjs-playground.com/#10RCC9#3 (stuffhedrons) http://www.babylonjs-playground.com/#10RCC9#4 (triangles) etc, etc dbawel and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 18, 2016 Share Posted October 18, 2016 We should create a feature scene for bjs homepage! Quote Link to comment Share on other sites More sharing options...
jerome Posted October 18, 2016 Share Posted October 18, 2016 oeuf corse ! Quote Link to comment Share on other sites More sharing options...
jerome Posted October 18, 2016 Share Posted October 18, 2016 and this works with the billboard mode : http://www.babylonjs-playground.com/#10RCC9#5 [EDIT] So you can play with legacy-like particles (sps billboard) AND particle intersections now : http://www.babylonjs-playground.com/#10RCC9#6 http://www.babylonjs-playground.com/#10RCC9#7 Quote Link to comment Share on other sites More sharing options...
dbawel Posted October 18, 2016 Author Share Posted October 18, 2016 @jerome - Outstanding! I wish I had this a week ago, as I'm too far into the projet to switch now. And it appears that @adam may have fixed the bug in Oimo (still testing), so the future is looking bright. Thanks for all of your hard work, and we'll all be watching to see what you do next. Cheers, DB Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 18, 2016 Share Posted October 18, 2016 Future is always bright with such a community JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 19, 2016 Share Posted October 19, 2016 @Deltakosh would this one be enough for a feature demo ("solid particle intersections") in the BJS site : http://www.babylonjs-playground.com/#PBVEM ? 1200 coloured boxes, tetrahedrons and polyhedrons bouncing against a flying sphere. Runs at 60 fps in my Chrome Quote Link to comment Share on other sites More sharing options...
jerome Posted October 19, 2016 Share Posted October 19, 2016 Can't stop playing ... @Wingnut told about some fluid dynamics, so I just tried some naive settings from the existing playground and : http://www.babylonjs-playground.com/#1QWKFV#1 well, there's 10K plane billboarded particles here, so for me ... chrome and a decent computer to keep 60 fps Wingnut 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 19, 2016 Share Posted October 19, 2016 I take this one: http://www.babylonjs-playground.com/#PBVEM this is perfect! jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 19, 2016 Share Posted October 19, 2016 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 20, 2016 Share Posted October 20, 2016 @Deltakosh unless you prefer this more polished version with no alpha but shadows instead (will work fine as soon as the PR fix is merged) : http://www.babylonjs-playground.com/#2BXZC 1500 solid particles, global bbox (for shadows) computed in the same loop than the particle computations, so extra-fast [EDIT] ooops, didn't notice the first version was already on-line in the BJS site JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
adam Posted October 20, 2016 Share Posted October 20, 2016 Here is a PG that uses instances instead of SPS: http://www.babylonjs-playground.com/#12SEYV#9 It's probably already been determined, but if you need your particles to collide with each other, you might as well go with instances because the bottleneck is going to be the physics engine. PhilT 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 20, 2016 Share Posted October 20, 2016 that's right Quote Link to comment Share on other sites More sharing options...
jerome Posted October 24, 2016 Share Posted October 24, 2016 new SPS optimization feature : boundingSphereOnly (default = false) If the SPS is created for computing particle intersections, we can now limit this computation to the particle bounding spheres only, what can usually be enough for tiny animated objects. var sps = new BABYLON.SolidParticleSystem("sps", scene, {particleIntersection: true, boundingSphereOnly: true}); This increases noticeably the perfs with big numbers of managed particles, as a BoundingBox requires 8 extra iterations per particle (each box vertex). [EDIT] In order to give you an idea about the gain, this former pseudo-fluid-dynamics PG, http://www.babylonjs-playground.com/#1QWKFV#1 , (beware before clicking, this is CPU intensive and can freeze FF) that was running at 60 fps in my Chrome with 10K particles, can now run at 60 fps with 25K particles checking their intersection on their bounding spheres only. adam, GameMonetize and JohnK 3 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 25, 2016 Share Posted October 25, 2016 Pending PR of a new feature related to intersection (fast bounding sphere intersection improved for spherical(-like) particles) : var sps = new BABYLON.SolidParticleSystem("sps", scene, {particleIntersection: true, boundingSphereOnly: true, bSphereRadiusFactor : 1.0 / Math.sqrt(3.0)}; The new paramater bSphereRadiusFactor allows to modify the bounding sphere radius : the bounding sphere radius is multiplied by this parameter. Example : with the factor 1 / SQRT(3), a spherical particle will exactly match its bounding sphere. As sometimes tiny animated objects (solid particles) can be approximated by little spheres, this is really useful to set their bounding spheres close to their own shape and then just use the fast bounding sphere intersection only. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 25, 2016 Share Posted October 25, 2016 validated and merged PG updated Quote Link to comment Share on other sites More sharing options...
jerome Posted October 25, 2016 Share Posted October 25, 2016 demo PG tomorrow (probably) Quote Link to comment Share on other sites More sharing options...
jerome Posted October 26, 2016 Share Posted October 26, 2016 Hello, Here is a set of PG examples to understand the differences between the intersection computation modes. As you may know, mesh or solid particle intersections are computed according to their bounding boxes and bounding spheres. In short, a mesh is inside its bounding box, and its bounding box is inside its bounding sphere, so the sphere is bigger than the box, what is bigger than the mesh. The intersection rules are those : 1 - if two bounding spheres don't intersect, then the related meshes don't intersect. 2 - Else, if both related bounding boxes don't intersect, then the meshes still don't intersect. 3 - Else, the meshes intersect. Solid particle intersections work the same way when you enable them in your SPS. The default mode is then to compute each particle bounding box and check (AABB) intersections between them, whatever the shape of the embedded particle. example 1 : default mode with a sphere, AABB bounding boxes intersections => http://www.babylonjs-playground.com/#29F0EG Contrary to what you can imagine, this is the most accurate mode to compute the intersections with the SPS. Here, you can notice (in purpose), that the blue particles intersect somewhat cuboid around the red sphere. I chose a sphere intentionally to make it very visible, but you probably wouldn't have noticed this with real solid particles (these are planar and billboarded) and another kind of shape than a sphere. This mode is also the most CPU intensive. If we don't mind about accuracy but need more performances, we can force the intersection computations on the bounding spheres only and no longer on the bounding boxes : example 2 : boundingSphereOnly = true => http://www.babylonjs-playground.com/#29F0EG#1 Now the blue particles intersect something spherical around the red sphere. This is its bounding sphere... farther from it, because, remember, the red sphere (mesh) is inside its bounding box, what is inside its bounding sphere. We would like to tweak this bounding sphere, to make it closer to its embedded mesh since we don't care about the bounding boxes. We can then moderate its radius by some factor. For instance, the bounding sphere, around a sphere with a radius R, has a radius of R * SQRT(3) I let you discover the maths behind by your own . So if we multiply the current bounding sphere radius by 1 / SQRT(3), the bounding sphere will have the same radius than its embedded sphere (mesh). example 3 : bSphereRadiusFactor = 1 / SQRT(3) => http://www.babylonjs-playground.com/#29F0EG#2 The bounding sphere now exactly matches the red sphere and the blue particles intersect right its surface. We can also play with this factor to produce the inverted result with higher factor values. Here's a small red ball protected from the water drops by an invisible force around it http://www.babylonjs-playground.com/#29F0EG#3 Have fun NasimiAsl 1 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.