Nvidia Flex Build

For those interested in trying out an experimental build with Nvidia Flex support:

I’ve also attached some Snippets to help get you started.

Note: Windows only, Nvidia GPU required

Nvidia Flex Solver COMP - functions much the same as the Bullet Solver COMP. Gathers Actor COMPs, runs the simulation, and updates Actor transform data
Actor COMP - can now also be used for Flex simulations, in addition to Bullet – for Flex fluid actors refer to the Flex page
Force COMP - consolidated forces into a single COMP – Flex only supports force fields
Flex TOP - grabs particle velocity/position data as a texture from an Actor COMP

FlexSnippets.toe (137.2 KB)


I stepped through the examples in here and recorded a quick screen cast so folks can see what’s happening - even if they don’t have the hardware / time to install an experimental build:


Very cool native implementation of flex.

I have done projects with a modified version of Vincent’s FlexCHOP. And a few features I would really like to see in this implementation.

  1. Anistropic info. This is key to getting realistic water surface look, as mentioned in the original paper that became Flex.

  2. Diffuse and density info. I believe it’s labeled as diffused particle in Flex. I need to look at my code. But these are very important to rendering water foams.

  3. Please expose something akin to the frame rate setting in Vincent’s implementation(I don’t remember the exact parameter in the Flex lib). It’s extremely important, especially if you want that slow mo look.

  4. Any chance of adding softbody, rigid body, and cloth support?

Thank you.



Thank you for your feedback, it’s much appreciated.

Anisotropy, density, and diffuse info are definitely things we can add. These would likely be added as options in the drop-down menu of the Flex TOP, similar to retrieving particle position/velocity info. In addition to that, we could add anisotropy and diffuse parameters to the Flex Solver COMP. These are exposed in the Flex API but are currently set to default values.

I’m not sure what you’re referring to about frame rate setting, but I’ll take a closer look.

Rigid body support is a work in progress. No plan for soft body or cloth at the moment.

I looked at the code, the frame rate thing Vincent implemented is something like this.
g_dt = 1/framerate;

Then g_dt is used to in the following call
NV_FLEX_API void NvFlexUpdateSolver (NvFlexSolver *solver, float dt, int substeps, bool enableTimers)

Looking forward to future updates!

Ahh yes. The Flex Solver COMP uses its me.time.rate for this, which you could modify by changing the timeline rate or by using a local time COMP.

A sample rate parameter would be better/more direct, however.


The sample rate and this time step really should be de-coupled. It allows for some very interesting and useful effects.

This way, the time step can be modulated without having to worry about the sample rate of all other related ops.

Thank you.


Strangely, just opening the flex snippets with the new build, they aren’t running. They say “Unable to create texture. something/something/actor4 does not have an Nvidia Flex buffer”

Wait, nevermind, I had to hit “start” on the comp

1 Like

Yeah, this is something we’d like to do, perhaps in the form of a Flex palette COMP.

1 Like

Very cool and fun to play with eric!

I did notice, not sure if I’m missing something, its a bug, or limitation of Flex ( don’t think so) but in the forcefield example it doesn’t seem like I can get a second force field to apply. If I add another, and deactivate the audio reactive one you had in there, then I can see the second force field starting to work, so I assume bug?

As well I recall some Vincent’s work in this had “secondary particles” that were generated from certain properties of the fluid sim, often used for wave “spray” and the like. Is that a feature of Flex that could eventually be incorporated somehow? Perhaps another particle data TOP that could be grabbed via the Flex TOP if the solver was configured to generate those extra particles?

So stoked for this stuff to be getting built in!


Thanks for the feedback, Peter.

Multiple force-fields are supported, so that’s a bug. I’ll look into it.

I believe what you’re referring to are diffuse particles. I’ve added a way to fetch diffuse particle position/velocity, anisotropy, and density info using the Flex TOP via the output parameter. Additionally, I added parameters to the Flex Solver COMP to control diffuse/anisotropy properties of the simulation.

Just a little bit more work to do but it should be ready to release soon. I can post a build here once it’s ready and I think we’ll also be adding it to the main 30k soon.

Here is a link to an updated Flex build, which also includes the latest experimental changes:

I also expect Flex to be included in the next experimental release.


  • added Anisotropy, Density, and Diffuse Position/Velocity output options to Flex TOP
  • added a sample rate parameter to the Flex Solver COMP, as well as a bunch of new ones under the Properties page, most notably the diffuse particle parameters.
  • added an option to define simulation boundaries using a bounding box (SOP)
  • bug fixes
1 Like

The anisotropy output is a 2D array texture. Is that going to be supported with a CPP TOP in CUDA mode?

I haven’t actually tested, but I think it should just work. Does it not?

Me neither… but it’s not so important. I also noticed a TOP input from my CUDA plugin is cleaned with zeros with this build.

Hey Eric!

Great stuff, thanks for the quick additions and fixes! A couple other thoughts after playing with it some:

  • is it easy to get the life ( normalized, absolute or both?) of the diffuse particles out?

  • does flex support any other sorts of forces, or just radial fields? In old shader based particle systems i’ve made up things like vortex and spiral forces, just curious if there is anything like this in the Flex API available.

  • I was wondering if something similar to the bullet feedback could be implemented where we get the ability to get feedback back into the system by manipulating position and velocity ( or maybe force acting on each particle?) and sending it back into the solver via textures would be interesting or possible. I don’t really know the implications but seems like a way to really “touchify” the implementation like the Bullet features have done.

  • i definitely second the desire for a screen space fluid shader example as well, could be quite sweet!

Great stuff, I hope to post some of my investigations as soon as I can!


I just tested this. The setup code actually works if I only write to layer 0, but breaks for more.

CUDA Programming Guide "A layered texture can only be a CUDA array by calling cudaMalloc3DArray() with the cudaArrayLayered (…) flags ". So maybe you have to enable it when allocating outputFormat->cudaOutput[0]?

The diffuse lifetime should come in as a normalized value in the alpha channel of the Diffuse Position texture, but I see now that it’s zeroed out. I’ll fix that.

Flex supports other forces for different materials, wind with cloth for example, but for fluids I believe it’s only force fields. There are a few different force field modes but they don’t determine radial vs. vortex. However, you should already be able to achieve a vortex effect with the current force fields by lowering vorticity confinement on the Flex Solver COMP. Unfortunately this is a simulation property so you can’t have different force fields with different behaviour in a simulation.

We do have plans for a feedbacking system in Flex similar to the one in Bullet, not sure when that feature will make it in though.

1 Like

Are you still having the issue with the inputs just being 0?