3D Physics substantially faster than 2D

Hello there.

I’m somewhat disappointed with the initial box2d integration in terms of features (it’s very limited imho), so, I decided to test the performance compared to physx constrained to 2d, for my surprise, I was consistently getting better performance with the 3d engine, so I decided to google for it and I found a stress test (https://dl.dropboxusercontent.com/u/883485/UnityPhysicsTest/UnityPhysicsTest.html), according to the author the 2d engine is indeed faster (although not much), however, on my machine, not only it’s slower but it also stutters like hell.

Physx integration is much better at the moment, it features more stuff like breakable joints and more joint types and if it’s faster or almost as fast as box2d, I see no reason not to use it, unless there’s a huge performance difference on some devices like android and ios, but it seems to me that on Desktop physx is still the way to go.

On that pyramid test, the physx version stays @ 60fps all the time, while the box2d version drops to 30fps when a ball is spawned, plus it stutters all the time.

Any comments on this?

I don’t see that at all. With the pyramid test, the 2D physics were 20fps faster (90 fps vs 70, no drops when a ball is spawned), and with the box test, the 3D physics stopped at 989 objects whereas the 2D physics stopped at 2140. No stuttering with the 2D physics.

–Eric

List Hardware Specs or it didn’t happen!

lol

I only said that, bc sometimes I wonder “Are they use Intel HD integrated graphics!?” as I have heard some weiiiiiiird things from those chips.

I don’t think the graphics hardware would have much to do with it, since physics is CPU-only. (No integrated graphics here though.) Maybe the 2D physics somehow use some kind of hardware vector instruction not available on the OP’s CPU? Or something?

–Eric

Interesting… your results are similar to the results of author of the test (on the box test about 1000 objects using 3D and 2000+ using 2D). My results are about 1000 using both engines. On the pyramid test, the thing is even more weird, the 3D stays like 60/22/60 and the 2d is like 20-60/12/55-60 (both are much better than the author’s results, but in my case 2D is slower), plus there’s a noticeable stuttering, specially when you spawn a ball, while the 3d version is smooth and fluid. Another thing is that here it’s vsynced to 60fps, it doesn’t matter if I force it off on nvidia panel… let me ask you something… are you on a Mac? I suspect this huge difference may be because I’m on Windows and both you and the guy who made the test are on Macs(?)… perhaps the Mac webplayer is more optimized for the 2D physics or something… this would make sense I think because it could pretty much re-use the optimizations for iOS afaik, and I think both engines are very optimized for it.

Yeah, I don’t think my graphics card is relevant in this case… and nope, my CPU is quite modern if you ask me.

I am on a Mac, but that’s not related to iOS, which is a different OS using a different CPU. Macs and Windows should be using the same code for most things aside from OS-specific calls as far as I know.

–Eric

2D boxes: 1662
3D boxes: 1228

(pc, i7 3.4ghz, gtx580, firefox, Unity Plugin version: 4.3.3f1)