NVIDIAGameWorks / FleX

Other
650 stars 100 forks source link

Custom solver shader #58

Closed AndreaCatania closed 5 years ago

AndreaCatania commented 5 years ago

Hi @mmacklin

I'm Andrea and I'm implementing Flex inside Godot Engine: https://github.com/AndreaCatania/godot/tree/flex (In this moment only water and tearing meshes are missing.)

By looking into the code of extension https://github.com/NVIDIAGameWorks/FleX/blob/master/extensions/dx/flexExt.cpp#L66

I saw that is possible to add a custom shader to the solving process. Would be really really helpful if you give me an example or a short guide on how this shader works in order to extend the possibilities of flex!

In this moment I'm working on a complicate simulation and the access to this feature would make my life really easy

Can you do it please? a short hint is enough Thanks you in advance AndreaCatania

mmacklin commented 5 years ago

Hi Andrea,

The best place to look is at the example forcefield code in flexExt.cu. See the UpdateForceFields kernel, basically that kernel can do anything to the velocities or positions depending on what stage of the Flex update you register it with NvFlexRegisterSolverCallback() method, so it is possible to implement custom constraints using this mechanism.

Hope that helps.

Cheers, Miles

AndreaCatania commented 5 years ago

Thanks you for your comment, I did it :)

I need last information, is possible to access to contact buffer "NvFlexGetContacts" from cuda function like is done for particles?

If not, Can you expose it as is done for particles and velocity?