AWS for Games Blog

The Winds of Change: Lumberyard’s Road to NVIDIA PhysX Integration

Authored by Doug Erickson and the Amazon Lumberyard Physics Team

When gamers think of gaming “physics,” they might think of realistic behaviors — simulated gravity, weight, wind, and motion. Or perhaps they think of vehicle dynamics, or ragdoll behaviors, or projectile velocities and weapon recoils. Overall, gamers think of game physics in terms of gameplay and visuals, and specifically a consistent set of interactive behaviors to aid immersion and reveal unique scenarios and puzzles.

(And dancing robots, too!)

Oh, but for those of us in game development: We know it’s so much more.

Game physics are everywhere in the worlds we create—from simple collision detection, to the relationships between entities and actors, to the very fundament of the levels we imagine, and the tools we use to craft new, original experiences. This intrinsic set of rules, behaviors, and relationships define the experience of our games.

For instance, imagine how a door to a haunted house opens: Does it suddenly swing wide, as though propelled by a gust of wind (or evil force)? Compare that to the sweeping motion of a player’s ballroom gown or the resistance and flames of a battle-damaged spacecraft, falling apart as it enters the atmosphere of a lost moon. Physics drive emotions as well as gameplay.

The best games are the ones that are built with physics and physical behaviors that are unique and complementary to the experiences you imagine. In fact, gaming physics touches every aspect of development, from positioning a simple mesh, to the winds that blow the smoke of a battlefield just enough to reveal the next wave of an ambush.

(A good physics library can make highly dynamic scenes like this achievable by even beginning developers.)

Since player immersion is often reliant on believable, expressive physics, the team behind Amazon Lumberyard decided to help developers achieve the flexibility they need to deliver their visions.

Three years ago, a small Lumberyard team in London set out to create a common interface that would allow any developer to add the physics and physical systems that best suited the experience they wanted to craft. We also partnered with our friends at NVIDIA to deploy PhysX, their outstanding open-source physics solution. Do you want to roll your own hyper-realistic set of rules for an anime-themed fighting game or a cyberpunk showdown? Create a Gem, compile it in, and use it. Prefer a highly-optimized and rich set of universal algorithms that leverages the power of a modern GPU? Integrate seamlessly with NVIDIA’s PhysX library.

As we investigated further and built prototypes, we realized that in the end, customers just wanted great tools first, and custom library integrations later. As Amazonians and Agile developers, we had to prioritize: What will get game developers up-and-running the quickest, with the richest experiences? And while the dream of a universal interface for all physics libraries and tools is far from dead, we pivoted to what we felt was the most comprehensive initial solution: Make NVIDIA’s performant and robust PhysX library the default system, and integrate it seamlessly with all aspects of game development in Lumberyard. This includes everything from basic raycasting, to full-blown cloth and destruction simulation. PhysX object editing is seamless in Lumberyard, such as when working with entities in Edit Mode, and will be integrated into future Lumberyard workflows and tools as well. The fundamental forces of nature are available to you everywhere!

Why NVIDIA PhysX? Well, it’s feature-rich. It’s industry-leading in flexibility and performance. It’s established. It’s open source-friendly. It’s free. And it’s just plain awesome! It was an easy call.

From Lumberyard Beta 1.18 to the current 1.26 version, we’ve rolled out PhysX-enabled features and deprecated CryPhysics ones, working our hardest to avoid regressions for our customers and justify the changes with more the flexible PhysX behaviors, APIs, and tools we’ve built. Let’s review some of the major updates, shall we?

  • Support for basic physical behaviors across in-game entities and components, including raycasting and shapecasting queries, colliders and collider meshes, mass and gravitational properties, and force regions. This work also includes integration with the new Viewport Interaction Model, which allows you to inspect and confirm physical behaviors from different perspectives, using common industry and gameplay controls. Place objects and forces, try ‘em out, and tweak the properties to your heart’s content — in real time!
  • NVIDIA Cloth support. This was a very commonly requested feature from our game dev customers, and one of the first features we worked to make available quickly and iteratively.
  • The White Box Tool, which enables the prototyping of entities for level design and construction. All entities created with it come with full physics-based colliders, so you can start interacting with them and tweaking their properties to find the behaviors that just feel right to you.
  • Support for customizable physical properties and behaviors for terrain and vegetation.
  • Support for PhysX-based actor ragdoll behaviors based on both global and customizable properties.
  • Support for particles with both global and customizable physical properties. A blizzard is just a bunch of snow sprites if there’s no wind!
  • Physics-based controllers for actors and other in-game entities. This allows them to interact with, use, and respond to physical forces in a natural way. (Well, natural for your game’s world, at least!)
  • Supports for joints, constraints, and joint modeling, in a way that respected our component-entity model and could also be tested and verified in real time within the Lumberyard Editor.
  • Integration with Script Canvas for the use of physical properties in dynamic gameplay, especially scene queries.
  • Full replacement of all previous CryPhysics functionality with PhysX-enabled equivalents. This change was partly for the future of Lumberyard development so we could build new physics-based features atop a performant library; but it was also for you, as it allows you to get new features faster and introduce your own in a flexible, familiar way. You can check out how to work with this system through the AZ::Physics APIs provided in a Lumberyard installation.
  • On top of all this, the new Starter Game 2.0 (introduced in Lumberyard Beta 1.24) is fully PhysX enabled, and you can dive right in to see how our features and tools work with it.

As we worked on these features, we also included examples in the PhysXSamples Gem, for both inspirational and illustrative purposes. It’s one thing to talk about joint behaviors in the technical documentation, and another thing to see it in action, so you can decide how to incorporate these into your own game.

(You can get pretty creative with the White Box Tool. Build out a spaceship mesh like this straight from the Editor!)

We’re planning to button everything up in a General Availability (GA) release in the coming months, adding in advanced behaviors for NVIDIA Cloth, and including support the NVIDIA Blast destruction library, as well as putting the final polish on the White Box Tool and PhysX integration. It may be the end of a long journey for CryPhysics in Lumberyard, but what lies beyond will be better still.

And what is after that, you ask? Well, that’s up to you! What do you want when it comes to Physics support? Have a preferred library, or a game idea centered around a different idea of immersion and “realism?” Do you have some thoughts on how to better integrate physical behaviors with other tools and game components with your developer’s quality-of-life in mind? Share your thoughts in the Lumberyard forums and let’s chat! The symbiosis between great game concepts and great game development tools is where the best customer experiences ultimately happen, after all.

As ever, thank you for supporting Amazon Lumberyard! (If you haven’t tried Lumberyard out, grab the 1.26 beta here and give it a spin, or maybe a roll, or even a yaw.)