368 points · by homarp · 8y ago · 117 comments
Sounds like a potential GDC or Gamasutra writeup.
Otherwise you run into situation where large deltaV, or very small deltaV completely break the physics calculations. The next is that rounding issue and precision with double still creep in and having a physicist engine that is deterministic for a given hz and float/double speeds up development time.
When you replay a series of inputs, you want the accompanying physics to come out the same. Solvers that use randomness in your engine will either need to have their RNG seeded with the same value or have the rng removed.
Another thing causing problems might be how your engine handles time or when it iterates over objects in a specific order relative to how they were added (might not have preserved that order in your snapshot).
There's many things that can go wrong.
Knowing only how much Army of Two stressed its cooperative network play nature (including in its title), that's my best lay guess of the strong reason the game wanted deterministic simulations.
The impression I got from dev team discussions/features on The Halo Channel/Master Chief Collection was that Halo was built that way: its network engine wanted rock solid deterministic physics, so all the replay/recap features added to later games were a "free" bonus they were able to build on top from that earlier netcode requirement.
Another thing to consider about a replay system is that you don't have to be perfect. What you as a player see isn't what the server(if you have one) sees, and it's not what the other player sees. Your view is only a best guess at that, and for most replay systems in games, they will also be best guesses.
In terms of this game in particular, it's a multiplayer coop action shooter so you want everything the behave the same way on both players machines. The player models should be in consistent places in the world, bullets should fly in the same direction on both, grenades and other physics objects should bounce the same way.
If these things do not happen then you will have diverging realities on each of the machines.
Havok was once the leader in this area, but they were refinanced in a down round, acquired by Intel, and then sold off to Microsoft. Now they don't seem to be very active. Their web site announces the new 2013 version.
(I used to work on this stuff. I'm responsible for the ragdoll-falling-downstairs cliche, first shown in 1997.)
Disclaimer: I work there.
The position based dynamics code is in a separate SDK called Nvidia Flex ( https://developer.nvidia.com/flex). Flex is closed source, runs on the GPU and is implemented in CUDA (Nvidia only).
Flex 1.0 did require CUDA hardware, but with 1.1 they added a Direct3D backend that runs on any DX11-class GPU.
Scrawk converted the code to C# in order to support Unity and implemented a Unity based version of the fluid dynamics code that runs on the GPU (using portable compute shaders instead of CUDA) as well.
https://github.com/Scrawk/Position-Based-Dynamics https://github.com/Scrawk/PBD-Fluid-in-Unity
The only game that I'm aware of that uses position based dynamics on the GPU is Claybook (https://twvideo01.ubm-us.net/o1/vault/gdc2018/presentations/...). Because PDB is basically an extension of Jakobsen style verlet physics (http://www.cs.cmu.edu/afs/cs/academic/class/15462-s13/www/le...) which is used in a lot of games (Fantastic contraption, Gish, World of Goo, various Bridge builders, etc.) In all cases the developers are using custom physics code and not using a library. This is very different than rigid body dynamics where most shipping games use a licensed physics engine (Havok, PhysX, Bullet, ODE, etc.)
See the other link currently on the front page: https://blogs.nvidia.com/blog/2018/12/03/physx-high-fidelity.... Gives some ideas of the rationale.
Vast majority of the time, most game engine's to solve this problem just let non interactive objects (cloud's, waves, lighting) to be calculated by the phyx sub-system, and only poking it now and then to prevent the phyx hardware from swamping to the CPU.
PhysX keeps two copies of the simulation, you read from one while PhysX is updating the other, and then they swap the pointers. You don't cross the PCI bus to get every position/velocity, that info is transferred in bulk at every step.
That said, not that many games use the GPU-accelerated parts of it; for a lot of gameplay physics CPU code path of PhysX works just fine and does not have special hardware requirements.
That's not true - UE4 games can be (and are) built against other physics engines.
https://github.com/NVIDIAGameWorks/PhysX-3.4/blob/master/Phy...
Does this actually work? If it has tangible benefits then perhaps the AOSP could do the same.
Come to think of it, it reduces the number of stat() system calls quite significantly, that can make a difference in large builds.
So far it looks more like a way to advance CUDA usage even further, by giving a free higher level library that's locked into it.
Assuming by hardware you mean GPU acceleration, then yes. It's not really a push for Cuda usage, most games that use physx don't use the GPU acceleration (not everyone has PhysX cards, and those that do are usually busy using the GPU for rendering), so in practice for 99% of use cases, it is open.
2) The contribution was actually not very helpful for nouveau, much of the information was already known. nvidia has done practically nothing since then to support nouveau in any meaningful way, with the exception of a one-off patchset to implement some support for Tegra.
I suspect you just found the first link that seemed to validate the point you are trying to make, without actually understanding what is actually (not) going on.
http://download.nvidia.com/open-gpu-doc/DCB/1/DCB-4.0-Specif...
> nvidia has done practically nothing since then to support nouveau in any meaningful way
There's an awful lot of stuff in that directory for that to be the case.
> suspect you just found the first link that seemed to validate the point you are trying to make, without actually understanding what is actually (not) going on.
Funny, I think the same thing when people say "nvidia never helps nouveau."
I think that sums it up nicely. Nvidia want the opensource driver to work just well enough that you can get a picture to install the proprietary one.
Currently Nvidia are complete jerks when it comes to helping nouveau with documenting their hardware.
The sad thing is that this experience is typical and expected for me by now. Nearly every time I install or upgrade Linux, I have to spend hours troubleshooting Nvidia driver issues. Cumulatively, several days of my life have been wasted on this. People are angry because Nvidia has made and continues to make bad decisions that result in a poor experience on Linux.
And it's not baseless. Where is their documentation on reclocking for desktop GPUs? Once they hid it behind signed firmware, doing it from nouveau became a major pain, because it requires complete blind reverse engineering. All this effort could be spent on making the drivers better instead, if Nvidia would have provided documentation.
It's the reason you can't use nouveau for gaming today on anything recent.
The point is that these two are completely orthogonal. It's like saying: what's the point of writing open source software for an x86 when the x86 RTL is closed source.
With an open source PhysX library, you can make PhysX work in any environment.
Not if their drivers on other environments dont support it. Consoles are all AMD, and NVIDIA only has 3-4% more market share on PC, while intel has around 70% of the market share. That's a really low number of platforms for a proprietary piece of tech.