http://flyclops.com/battle-of-the-ios-physics-engines-197
Interesting.
Very.
Would like to see a pure PhysX test directly on iOS that is not being driven by Unity. Would also like to see PhysX and ODE stacked up against each other. I am wondering if it is some odd interface issue between Unity and PhysX that is causing the disparity, but also as the article mentions, comparing a 3D physics engine against a 2D engine is not a completely equal comparison.
It is Box2d
I’ve used box2D many times, it is fast, but cocos was likely batching, and I don’t know if some of the slowdown was visual or what? did the author run these tests on a blank screen for example?
Cos cocos will render a lot faster out of the box for just doing a few basic draw calls and unity needs to be set up right for decent speed in drawing.
To be fair without the GPU acceleration PhysX tends to not be that great. You’d be better off with Bullet or even ODE in that situation. Somehow I doubt you’re getting GPU acceleration with PhysX on an IOS device.
The other thing is of course that 2D physics is somewhat less complex than 3D physics. I was actually quite impressed with how well PhysX held up in that test at only about half the speed (well either that or not really impresed with the 2D physics engine).
Comparing the two is not exactly fair cause physx as any 3D physics is doomed to lose, the overhead of 3D spatial tree management is on a whole different level than doing it in 2D like Box2D or Chipmunk.
This lower degree of dimensions has various pretty deep consequences especially on the math and mathematical stability end. Or put differently: if box2d would need to have all the complex math in to handle the whole physics resolution within float boundaries under the same premises the 3D physics library need to, I’m pretty sure it would lose badly.
None the less it naturally does not remove the use and need of both of them and strengthens the reason why you should use a 2D physics library for a pure 2D game and not try to neutre PhysX or 3D Physics until it looks like the unwanted child of a 2D physics library, cause it will not make you happy on the longer run
The unfortunate truth. Oh, how I would love to have the best of both worlds at the same time, haha.
hehe that would be the optimum but none of those investing the thousands to hundreds of thousands of hours on the 3D physics libraries has any interest to waste time in a nieche field with little to not financial backup.
Havok even less with its addon technologies that wouldn’t work or even make sense on 2D
For build size reasons you wouldn’t want a jack of all trades, having one or the other is definitely favorable. Thats where UT comes in and a setting that allows you to define if you want 2D or 3D physics and accordingly it uses such a thing. Problem is there is basically no physics engine in 3D that has a feature wise comparable 2D counterpart and vice versa so this is between a small and a complete nightmare
I remember Box2D being ported for use in Unity for 2D games. I wonder how much better that would run.
I don’t think it’d even be as fast as physx for ios (which is where this is important, for mobile) because it isn’t native C++ code nor anywhere near as fast. It’d probably break even best case. c# or js is around half the speed of C++ native compiled code.
A DLL however? now you’d be talking. I’ve used box2D on ios for a while in the past, and before that, in flash, and its a very capable engine, but I prefer physx for development times. The way unity has it all set up is so much faster to develop with.
Not really, “in the long run” (maybe next year ! when quadcore 2.5 GHz Cortex A-15 arrives) - the performance difference between 3D phyics and 2D Phyics in 2D game would be negligible to human perception as CPU performance improves to the point it renders the issue irrelevant - just like on the desktop nowadays.
This isn’t surprising at all, to me atleast. The overhead of 3D calculations, even with a ‘fixed’ dimension is going to be orders slower than a 2D simulation. Not only are the trees simpler, but there are tons of mathematical shortcuts one can take in a two dimension situation as opposed to three dimensions regarding vector operations.
On top of that, there are simple mathematical consequences that could easily slow the whole thing down. For example, the dot product will have an instruction ratio of 3 to 5. That itself is going to add up.
Furthermore, I wouldn’t even be surprised if a port of Box2D in C# ran as fast or faster than the PhysX implementation. While C# might be 50% slower, according to that chart, it would still be faster than the native PhysX implementation. If you look at the test with 171 rigid bodies, PhysX is running at 30fps while Box2D is still capped at a full 60. Even if the C# port was 50% slower than native, you’d still have better performance.
The step from 2d to 3d is magnificent… So not really a surprise that PhysX is slower here, since it does not have a “2d only” mode. Also PhysX is optimized for GPU and not CPU…
This nonsense about it being optimised for the GPU and not CPU has to stop. Certainly it has GPU optimisations - for the PC. You can’t get it going on mac or any other platform.
Physx wasn’t invented by nvidia nor was it invented by the parent company physx. Originally it was called NovodeX Physics, and was aquired/abosorbed into Ageia, who added path for HW Accelerated physics ops like vectors, and other shortcuts, which eventually was bought out by nvidia.
It’s still basically the same cpu optimized novodex physics and not much changed. Some stuff was wrapped (it was bloated with low level commands). I used to use them all back in the day.
Performance wise, its never been a leader. nvidia rewrote most of it for nvidia physics 3, so if you wanted a speed boost or to thread it properly, then you’d need the new version.
edit: the wiki explains better than I do: PhysX - Wikipedia
Basically physx isn’t really optimised for anything at all, just simple enough to be hardware accelerated in places. There aren’t any platform specific optimisations… and I guess thats why it can be GPU accelerated.
But by contrast bullet and others do have platform specific optimisations. I wouldn’t be shocked if they were faster in some cases.
Lastly - one should note that the testing was not particularly extensive.
One simple scene that works to Box2D’s strengths - and we don’t know how he set up the unity simulation (could have made mistakes).
So while it’s certainly something to keep in mind - there is no guarantee it’s going to be accurate in your situation.
+1
I’ve written a 3d rigidbody physics engine and I can say that the difference is huge. Everything is simpler and faster in 2d.
It’s just not fair to compare a 2d physics engine to a 3d physics engine when simulating 2d worlds, the 2d engine is obviously more optimized for the case.
Yes and one would imagine it excels at … boxes!
More cores have no impact at all as Unity forcefully disabled physx multithreading, on ALL nonconsole platforms (it would by default offload itself to multiple cores. Not as optimized and fast as bullet which beats it easily on that end, but still some worlds to dimensions faster than it runs in unity at the time especially with medium to high complex rigidbody environments)
So all that the Kal El at 4x 1.x ghz will bring is energy saving cause 1-2 cores will be able to gate down to let the other two run faster
I didn’t read the final posts in this thread, i may could be off-topic at this point but here is:
I’ve also used box2D with (cocos2D) and is indeed hellish fast. But is doesn’t make any sense comparing PhysX which is a fully featured 3D physics engine with a simple 2D engine. PhysX not only have a third dimension (which adds even more calculations into the table) but also there’s more than just simple collision-detection inside PhysX, lots of stuff mind you.
One dimension sounds like one little step but is indeed more complex than that. For example when you work with matrices, add only one extra dimension and the whole thing completely changes, i mean, you’ll end up with a hellish amount of calculations that you need to do. No matter what you do, solving a system of equations with one extra unknown, do some cross products or elimination, one extra dimension changes everything!
I’m outa here! ^^
Didn’t quickfingers plug box2D into Unity before he used PhysX and said it was slower than PhysX? I remember something like this, but i may be wrong.