Close
Asset

Complex Physics with both Flex and Bullet solver

Hey everyone!

I’ve been working on something exciting: a complex geometrical scene powered by both the TD Physics Engine NVIDIA Flex and BULLET SOLVER. Let’s break down what’s happening here:

Chain Simulation with Bullet

The chain is built using Bullet physics, with a crucial detail:

  • Collision SOP: The actual colliders are simplified as boxes—a great starting point from the snippet example

Key Concepts:

  • Finite Mass = Can move (affected by external forces).

  • Infinite Mass = Immovable (no force can displace it).

Chain simulation? Done!  

Now, onto the crazy part:

 

Per Primitive Collision via NVIDIA Flex :

The idea of allowing 3D object primitives to move independently came from a brilliant tutorial by Denis Novikov (a true hero of GLSL!):Watch here

 

Theory Recap:

  • Every primitive has a center.

  • Using the vertex shader, we can access interpolated primitive attributes via the GPU.

  • By subtracting the primitive center from its vertices, everything resets to zero.

  • We then use a texture sampler to add the primitive center back, allowing us to control primitives via textures!

 

Integrating Flex

With each primitive's center stored in a texture, we can instantiate them using ActorCOMP. Sound familiar? 

Caveat:Flex has a theoretical particle limit. If the particle radius is larger than the minimum distance between neighboring primitives, collisions are triggered too early.

  • Minimum radius allowed : 0.001 (going smaller isn't recommended).

Flex Simulation Data Flow

  • Position Texture: Sent to glslMAT to control primitive centers.

  • Velocity Texture: Used as feedback for smoothing or applying external forces

Flex Object Types in TD

  • Flex allows objects to behave as:

    • Fluids

    • Emitters

    • Infinite Static Mass Objects (can still move and collide).

    • Linking Bullet & Flex: Manually add colliders using CHOPs and Actors. While automation (e.g., replicators) is possible, this approach works for demonstration!

Gravity & Dual Simulations

To ensure gravity affects only certain elements:

  • Flex Gravity: Set to 0,0,0 (active only during collisions).

  • Bullet Gravity: Enabled for colliders.

Use Keyboard controls:

  • 1 = Reset both simulations.

  • 2 = Play both simulations

Why Do This?

For fun! But also, I’m fascinated by real-time physics on geometry.TouchDesigner lacks one-click tools for cloth or deformable bodies, but NVIDIA Flex offers a foundation similar to PhysX 5, used for training robots with precision.

With compute shaders, TOPs, and the math already in place, per-primitive collision in TD is possible—and it’s only the beginning!!

Et voilà:

Best,

Simo

Asset Downloads

Comments