top of page
  • Writer's pictureDoğa

PhysX 4.1 & Nvidia Blast Integration on Unreal Engine

Updated: Jan 30, 2023

Introduction

Unreal Engine 4 still uses mostly outdated PhysX 3.3 as its physics engine, and it's not perfectly working in terms of performance & stability anymore. Epic wanted solve this problem with completely getting rid of PhysX, and developing their own physics engine, Chaos. Since Chaos is still in active development, I wanted to experiment with Nvidia's brand new destruction system "Blast", and update PhysX to get more stability with the Blast plugin.


NVIDIA Blast Integration

I've faced various problems during this integration step, and it was kinda challenging for me, especially with lack of rendering knowledge of mine.

First problem was plugin's maintenance status. It was updated for 4.20 release lastly, and then abandoned by the devs. The whole plugin was in unusable state when I started to work on it, because of major rendering pipeline changes in 4.22 release. I've dived deep into source code of the plugin, and fixed each single compile error as the first step of the integration.

Second problem was plugin's own rendering implementation, caused by rendering pipeline change that I've mentioned above. Fractured chunks were randomly blinking, or sometimes were completely disappearing. That was mostly caused by "Dynamic Index Buffer" implementation of Nvidia developers directly into the engine source, because of 4.22's rendering changes. So that, I've had to clean up those changes back from rendering module of the engine, and utilize "Zero scale bone" method to make fractured chunks disappear correctly "only in need". I've gathered changes for those two mentioned problems in https://github.com/dyanikoglu/UnrealEngine/commit/5389caa228fdea430ff4f8a8852d4eba899fb61b (It's required to have Unreal Engine repository access to see the contents of github links in this page)

Third, and most annoying problem was the DDC caching mechanism of Unreal Engine. It was not properly storing Blast meshes, which was causing each Blast Mesh to derive from "first" blast mesh created in the project. So, it was being possible to end up with a sphere shaped blast mesh with a cube's collision data, which is funny but annoying at the same time. After huge amount of debugging, I've discovered the issue was caused by a skeletal mesh related optimization in DDC module, and as the solution, bypassed that optimization with a boolean flag https://github.com/dyanikoglu/UnrealEngine/commit/ef204c296113c977e21c8b521da656d0e668dfd9

After fixing those three major problems, I was able to make Blast plugin work on Unreal Engine 4.25. After doing some amount of testing, I've applied some personal bug fixes & performance improvements to improve overall stability of the plugin.

I've also created a pull request for Nvidia's Unreal Engine fork, but it didn't get any response because of being abandoned by the devs https://github.com/NvPhysX/UnrealEngine/pull/624

The final result was satisfying enough, as seen below:


PhysX 4.1 Integration

After some amount of work with Nvidia Blast, I've noticed most of the features were not working like how they're introduced in official Nvidia blogs/videos. That was mostly caused by outdated PhysX version, and because of that, I wanted to update it to latest release, which is 4.1. I was mostly aiming for making PhysX 4's new Temporal Gauss Solver work, because it was a real game changer for the overall stability of the physics simulation.

Unfortunately, it was not possible to do a direct version upgrade by replacing old PhysX SDK with the new one, as you may have thought. I had to completely wipe PhysX SDK and its remnants from the engine (Including APEX Cloth, Destruction, Vehicle source code), and remove hardcoded PhysX 3 stuff from physics module of the engine https://github.com/dyanikoglu/UnrealEngine/commit/67d64fd08bc9b7fadd443e50a2522f8b267d79de

After completing that extensive cleanup, I've just added untouched PhysX 4.1 SDK as a new 3rd party dependency, and applied required changes into Unreal Automation Tool (UAT)'s physics binary compile script. That was another huge work itself, because the script also had lots of hardcoded stuff for PhysX 3, and it supported builds only with Visual Studio 2015 compiler. I've implemented required changes with more generalized approach without hardcoded stuff, and made the script able to compile PhysX 4.1 SDK binaries for the engine with Visual Studio 2019 compiler. Lastly, I've fixed compile errors & implemented new configuration values of PhysX 4 into engine's Physics Settings panel https://github.com/dyanikoglu/UnrealEngine/commit/4df72cc2302f146412effff84ce17e50e5b24cfe

Rest of the related commits can be found on my Unreal Engine fork, https://github.com/dyanikoglu/UnrealEngine/commits/4.25-PhysX4%2BBlast

After successfully compiling the new PhysX binaries, and launching my Blast sample project with those binaries, the difference was huge. You can view some tests I've made with PhysX 4.1 & Blast below.​


A quick comparison between Temporal Gauss Solver & PhysX 3 Solver (See how cubes are incorrectly getting stacked on PhysX 3):


Nvidia Blast without Temporal Gauss Solver:


Nvidia Blast with Temporal Gauss Solver (Chunks are more stabilized compared to standard solver):


Chaos Physics's destruction demo scene recreated with Nvidia Blast:


A test with one of my pet project and actual assets:


Lastly, demonstration of a full implementation into Project Borealis:



320 views1 comment

Recent Posts

See All
bottom of page