Simple GPU Cloth Sim


Still having fun doing sims with GLSL shaders, this time it’s cloth from the Stupid OpenGL Shader tricks NVIDIA paper. Rewind to first frame to properly init the sim.

Little demo on vimeo :


Note Added By Derivatve: More up-to-date version for 099 available later in the comments.
gpucloth.toe (10.6 KB)


This is great! I was eying the vimeo last week. You are really cranking these GLSL gems out! I’ve been very interested in porting more of these kinds of things, but really still don’t have a full grasp on the methods. These GLSL physics networks of yours are extremely useful for learning this stuff! Thanks for sharing!


thx so much for sharing all these!


this is wonderful. you are really steaming thru the GPU stuff!

the more examples we have in touch the better.code still makes me dizzy, so it’s great to have lots of existing stuff that actually works.

I think the touch community is starting to reach a critical mass where lots of cools stuff will happen more easily. I look forward to seeing (and making!) more of it.


Thanks for the nice words, glad you enjoyed it!
It’s been some time since I wanted to try gpu sims, but all the code needed for setting up and swapping textures and feeding parameters always put me off, so touch is great for that :slight_smile:

Hi Guys,

Having a little trouble getting this file to draw anything… It seems there are no compiling errors with the shaders etc, and everything seems to be running… just no cloth! Wanting to get an understanding of how it works as a base for an up coming project.

I know my problem explanation is a little vague :blush: but any help would be much appreciated!

Ollie :smiley:

Hi Oliver,

Just had a look at the file in Touch088 10780, fix was easier than I thought, you just need to put active on for the cache2 top and rewind.
Then the physics2GLSL complains about infinite recursion, which it didn’t in Touch077, but it works!


Just started playing with this again. I’m trying to turn it into a multi-touch example.

Is there any way to get touch to stop complaining about the recursion loop? Maybe the cache system could be replaced with feedback TOPs? The error is causing weird things to happen in the latest version of Touch.

Hi Matthew,

I’ll have a look, I remember seeing that recursion loop error, but can’t remember if I could fix it.

Unfortunately the cloth uses a verlet sim that requires position at the last frame and the frame before that instead of storing velocities, hence the cache TOPs. Feedback TOP will only give you the last frame.

I wish in general there was easier/more control about TOPs feedbacks, though it’s probably not easy to implement in a node based tool.

How do you guys get this to appear in render?

Everything seems to work except the render in td99, it appears in geo and camera alright

Anyway I can fix that? this in insanely beautiful!

Have I overstepped on some VIP conversation here?
Would be cool if more than 5 people can operate this patch.
Do you need commercial version to run this?
We could watch so many tutorials whereas, fiddling with this insane patch is a bit more straight to the point I find personally. And its most beautiful thing I ever saw done in Touchdesigner so far , not kidding. If its top secret info , I can understand, no worries.


This file was originally created in 2010 with TD077, so probably needs a little update :wink:
I’d recommend looking into upgrading the shaders from glsl 1.2 to 3.3 and see how that goes.
Appears to work fine with TD088 if you want to play with it.


Salut Vincent. felicitations

Glad someone’s alive here.
Ok no quick fix for this one, I see.
On day touch designer will totally fusion with GLSL I’m sure of that.
for the moment buffers and opening ports is a bit messy for me specially without good example.
David made a cool example with 4 buffers shader toys, we need more like that.

Ok I will take look at things from glsl1.2 to 3.3 thx for tips. good luck

Amazing work vincent!! (8 years ago :smiley:)
I’ve updated the renderer a bit so it works in 099 as well.

gpucloth.tox (12.3 KB)

Tim u rock! I was hitting my head against screen here thinking, shit if it was incompatibility due to differences between glsl1.2 and 3 would it not show up in ‘‘info’’ that sort or thing.
What did you do to get it to work?

it looked like the render shader was based on an old phong shader of touchdesigner (not sure, before my time :slight_smile:). So I exported a new phong shader and copy/pasted the parts that they renewed (TDLightning, matrices, etc.)

If you want, you can also copy/paste the cloth specific code to an exported PBR material, to make it even more funky :smiley:

Having a little trouble getting this file to draw anything… It seems there are no compiling errors with the shaders etc, and everything seems to be running