Best way to render softbodies...

Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Best way to render softbodies...

Post by Zeal »

It seems like its asking a lot of the CPU to render softbodies. I mean you need to not only update the vertex positions every frame, but you also need to do the normal calculations. Plus if you want your soft bodies to have normal maps (not common, but could be fun), thats another tangent for the cpu to calculate every frame.

I wonder, has anyone tried offloading some of this work to the gpu? Or are there any other tricks when it comes to rendering lots of soft bodies?
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: Best way to render softbodies...

Post by mickey »

you could probably pass the offsets to the vertex shader and have it done there, dunno.

I use the traditional way, locking, adjust vertices, unlock with DirectX.
Zeal
Posts: 47
Joined: Thu Oct 18, 2007 6:49 am

Re: Best way to render softbodies...

Post by Zeal »

you could probably pass the offsets to the vertex shader and have it done there, dunno.
Only way I could think of would be to write the vertex positions to a texture, then you could use this texture in a shader (3.0+) to position the verts. The point of putting the position in a texture would be so you can also use it to generate normals/tangents in another shader. Seems tricky but I imagine it would work...

I just dont see any other way to do it besides the obvious 'calc everything on the cpu, and upload it all to a giant vertex buffer every frame' technique.
yassim
Posts: 12
Joined: Tue Jun 26, 2007 2:33 am

Re: Best way to render softbodies...

Post by yassim »

Not trying to be rude but, Honstly I would not bother trying to get the GPU to do something funky for this.
The cost of simulating the Softbodys is most likely going to be far more than then packing the verts and using the same data to calc the normals and tangent.

Doing the calculation for the tangent can give you the normal on the way through.
They are most likely nice straight runs of memory, with even a 1 SB to 1 renderable data struct.
So if you really wanted to you could them in parallel.

Regards,
Yassim