PDA

View Full Version : GPU Cuda fluid solver for maya


Vinz9
03-04-2011, 01:17 AM
Hi,

Lately I've been interested in gpu simulations, especially fluids (I'm a bit jealous of the ILM fluid solver ;)), so I made a port of the GPU Gems articles about fluid simulations over to Cuda and maya.
It runs about 5 times faster than maya's, but there are lots of options missing, so it's not at all production ready.
Anyway I now have a lot less free time to continue it, so I'm releasing it in its current state with the source code, it was mostly an exercise to learn cuda anyway.
Still hope to improve it in the future, I need to re-read Robert Bridson book, but don't hold your breath!

Vimeo Vid (http://www.vimeo.com/20625705)
Plugin page (http://www.foliativ.net/book/index.php?post/2011/03/04/Cuda-Fluid-Solver-Plugin)

Vincent

Horganovski
03-04-2011, 04:45 AM
Very good of you to share this, the video looks great. Just got a cuda-capable card recently so looking forward to giving this a spin. Thanks.

Cheers,
Brian

Skoczylas
03-04-2011, 05:17 AM
That looks realy promising. Please keep us updated!

ganzo
03-04-2011, 07:30 AM
Ah most excellent...I had also been going through gems3 but trying to move it all to openCl...this gives me a nice head start....thanks for this!.

thematt
03-04-2011, 07:00 PM
super l'ami!! :applause:

czaps
03-07-2011, 01:35 PM
wow !!!

really impressive stuff ! :bounce:

greetings

czaps

Vinz9
03-07-2011, 02:05 PM
Thanks everyone :)
On closer look, for those who want to try it there are some dlls missing in the download, like the cuda dll (so you don't have to install the cuda toolkit 3.2) and the glew64 dll, I'll upload a new zip soon (I'm at work right now)

Vincent

haggi
03-07-2011, 07:49 PM
Very impressive, and indeed I had problems running the standalone as well as the plugin. I got the error message that the cudart64_32_16.dll is missing.

Vinz9
03-07-2011, 09:22 PM
Ok, new version of the archive is up with the missing dlls included.
For an unknown reason, density doesn't get advected (ie the fluid doesn't move) with the 3D solver on my laptop's geforce 8600M GS, the 2D solver does work though.
I'd be curious to know if the problem arises with other cards.

Vincent

JupiterSunset
03-08-2011, 05:28 PM
whoa, awesome!
works like a charm here (quadro FX 3800)

is this meant to be renderable just like Maya's native fluids?
maybe I should rtfm, but all I get is a black image, no matter what lights or settings I add/change.

thank you & keep up the great work!
philip

Nechoj
03-09-2011, 08:14 AM
Great Work!!!
I tried the solver on a FX 5600 and like you said the 2D version works quiet well, but in 3D the fluids don't move. If there is any solution to the advection problem, please let me know.

@JupiterSunset does the 3D Solver work on your machine?

Vinz9
03-09-2011, 08:28 AM
Hehe, yes you should rtfm ;)
Nope the hardware preview of the fluid is not directly renderable, though you can still hide the wire cube (there's a checkbox) and make a playblast.
However the density can be copied to a maya fluid container, which can be rendered as a standard maya fluid with maya software or mental ray.
It is set up with the mel procedure in fluidsetup, just unhide the maya fluid in the group, and uncheck preview and displayslice on the cuda fluid, and the density will be copied in the maya fluid container.
But the copy each frame has a cost.

I'd love to push the rendering to take into account occlusion geometry, other objects casting shadows, scattering, multiple lights and all, but I'm doing this in my spare time so...

Vincent

Vinz9
03-09-2011, 02:19 PM
Thanks Nechoj!
Hum, it looks like the problem is related to the cuda compute capability of the card, the FX3800 just like my laptop card is a bit old.
Not sure what feature of compute capability 1.3 I used is not available with older cards.

Irakli
03-09-2011, 08:22 PM
Same thing on FX 4600

Nechoj
03-10-2011, 09:11 AM
I tried it now on a FX 5800 and it worked. It depends (like Vincent said) on the CUDA compute capability version and the FX 5800 is version 1.3 while FX 5600 is version 1.0. Maybe someone finds out why the solver doesn't work on the lower version and show it here. There are a few differences like e.g. the max. number of resident warps per multiprocessor as you can see here: http://en.wikipedia.org/wiki/CUDA or even the memory size (but I think then it would give an allocation error or am I wrong).

Jochen

delphi88
03-10-2011, 12:29 PM
it will be nice to see some tutorial for it ;)

rBrady
03-10-2011, 03:08 PM
please please please productize this. If you refine this so its production ready, sell it at a reasonable price, then we all have a supported high quality fluids engine in maya. If you can make money at this its a good thing for everyone. Free projects sometimes fall by the wayside.

JupiterSunset
03-10-2011, 10:09 PM
Hehe, yes you should rtfm ;)
Nope the hardware preview of the fluid is not directly renderable, though you can still hide the wire cube (there's a checkbox) and make a playblast.
However the density can be copied to a maya fluid container, which can be rendered as a standard maya fluid with maya software or mental ray.
It is set up with the mel procedure in fluidsetup, just unhide the maya fluid in the group, and uncheck preview and displayslice on the cuda fluid, and the density will be copied in the maya fluid container.
But the copy each frame has a cost.

I'd love to push the rendering to take into account occlusion geometry, other objects casting shadows, scattering, multiple lights and all, but I'm doing this in my spare time so...

Vincent

thank you Vincent, will try!

just to clarify: I'm working with the (apparently) older
FX3800, and can produce beautiful volumes in 3d,
2d works anyway.

to make this a product is a good idea, although
Vincent releasing the source doesn't look like this
was the way he had in mind...?
merci
philip

merlin74
03-24-2011, 02:53 AM
First, thanks for this nice release. I have been thinking about building a CUDA fluid simulator for MAYA for some time. You gave me a good starting point.

I found with nthreads = 4 it works on my old 9600GSO while the density doesn't move with nthreads = 8. It is definitely a compute capability limit. For old CUDA cards, a block can only contain 256 (4x4x4) threads. That number can be much higher for newer cards, I assume.



Thanks Nechoj!
Hum, it looks like the problem is related to the cuda compute capability of the card, the FX3800 just like my laptop card is a bit old.
Not sure what feature of compute capability 1.3 I used is not available with older cards.

Vinz9
03-24-2011, 10:37 AM
@merlin : thanks for tracking precisely the problem, I'll put a quick fix in the next release. Anyway if you have an old card, speed gain should be much less, so...

@rbrady : could be interesting, but it would all get much more complicated than doing it as a hobbyist... (support, licensing scheme, actually making it production ready...)

Vinz9
05-03-2011, 11:54 PM
Hi,

I added a basic hardware particles system, also in Cuda, which can be advected by the cuda fluid. You can check it here http://www.vimeo.com/22916953

Vincent

Kakkoii
05-04-2011, 01:32 AM
Great work, can't wait to try it.

I'm having a problem getting it started though. The plug-in loads without error, and I have the DLL's in my bin folder. In your ReadMe, it says to first execute initCuda(), but when I do, it says it cannot find such a procedure. I must be doing something wrong.. But what?

Thanks.

edit: Nevermind, got it to work. I trusted that's all I needed to execute, but I had to actually look in fluidsolverSetup.mel for the full code I needed to execute...

global proc initCuda() {
createNode initGLCuda;
}


I can't get your scripts to do anything though =/. Does the template code not work as a stock example that doesn't require modification? I'm no Mel expert, so it's helpful to be given an example script that works off the bat to have something to work from.. Could anyone point me in the right direction, or provide me with a complete example script?

Dextron
05-04-2011, 07:04 PM
Oh wow.

I am finally glad I bought a powerful CUDA card.

redpawFX
05-06-2011, 08:12 AM
This is pretty awesome! I have a slightly older card and had to recompile the 3d standalone example
to only use 4 threads

its this line in computeGridSize in fluid3D.cu

void computeGridSize(cudaExtent res, dim3 &blocks, dim3 &threads, int &bx){

int nThreads = 8;
to:
int nThreads = 4;

and I can now see the 3d fluid moving, so thats one thing fixed.

however the two new examples with the particles seem to not work at all.
upon looking at the code, it appears you're using an old , deprecated header/library called
GLaux.h and It might be the lack of this library or something else quite particular dll wise that you have on your system that a default install of the nvidia / cuda stuff (3.2-x64) on windows 7x64 just doesent have. any ideas what it might be?

I'm cloning your project to github, if thats cool with you, Vincent?
https://github.com/redpawfx/cudaFluid

I'm going to attempt to start cross platform compiling this under linux
Along the way I think this will definitely be a learning experience in cuda and simulation code,
which is exactly what I'm interested in .
I too am jealous of ILM's toys :-)

thanks again
-redpawfx
(johnc)

azshall
05-10-2011, 02:03 AM
Impressive. Would love to see this pushed further! Waaaaaaaay faster than the Maya native solver

Vinz9
05-10-2011, 08:24 AM
@ azshall : thanks, but yeah lots of features missing yet

@ redpawFX : I was aware of the nthreads problem, but didn't get round to make a little function to choose the optimal number of threads depending on the GPU.
Isn't the particles not working problem related to the number of threads also?
Glaux was a quick attempt at using sprites, but the code is commented out in the end. You can remove it completely if you think it may cause a problem.

Putting it on github is fine with me, I'll link to it from the webpage. It was on my todo list to use sourceforge/googlecode/github/..., but I'm not too familiar with the the different source control systems, will have to check how it works.

That's cool if you can compile it to linux, also something on my todo list, but I need to install a linux distro first!

@ kakkoii : the scripts should set up something working, hope you got it to work. the iniGLCuda node was just a quick hack it should be possible to have this automated.

@Dextron : hehe I think interesting things are happening in the cuda/opencl realm, the new fancy hardware accelerated renderer/pathtracers look cool too.

redpawFX
05-10-2011, 05:40 PM
"Isn't the particles not working problem related to the number of threads also?"

Ah Yes it might be...

"Glaux was a quick attempt at using sprites, but the code is commented out in the end. You can remove it completely if you think it may cause a problem."

I did notice that some stuff was commented out , but I didn't delve much deeper, even commenting out the include for glaux still did not compile out of the gate and I didn't go much further.but now that I know what it was in there for I'll have a bit more of a hack at it and see what I can come up with :-)

Github is definitely nice to use, I also use smartGit which is a nice front end to git, and it interfaces with github accounts pretty well too.

thanks again :-)

-johnc

aquathinker
05-22-2011, 05:14 AM
Great work!
I just have a question, the particleSystem can not be rendered in maya, does you have any idea?

Thanks.

Vinz9
05-23-2011, 09:15 AM
Hi aquathinker, thanks. The particles can not be rendered yet, I'm on two tracks, improving the hardware rendering (sprites, approximated shadows) and integrate it with the maya hardware renderer, and copy the particles back to a classic maya particle system so they can be software rendered (but copying them will slow things down). Or maybe a cache system that would create a nparticles cache that you could load for maya particles or something like that.

aquathinker
05-23-2011, 11:02 AM
Hi Vinz,
Thanks for your reply. I am very interesting in improving the hardware rendering and integrate it with the maya hardware render.
I have done some work to copy the particles to maya particle system, but it still have some problem, I will send to you if I have the problem. Obvious, it will be very slow. Hope that you can realize the first idea.

Vinz9
05-24-2011, 08:13 AM
I have just implemented the self shadowed particles sample from the cuda sdk, it's quite promising. Else I think I'll try to make the plug directly write a cache in the GTO file format (http://www.tweaksoftware.com/products/open-source-software) from which I have heard good things, as I'd like to keep the plugin the most application independant possible. Looks like it can be directly rendered with renderman, and there are example plugins for maya and houdini particles.

Vincent

Vinz9
07-22-2011, 12:53 PM
Ok, I had a go at compiling a linux version, I had some problems along the way (I'm a windows guy and I first had to install Linux ;)), but mostly it went quite smoothly.

So it's compiled for Maya2012x64 with GCC 4.4 (and not 4.1.2 as recommended in the maya docs), and it works in Ubuntu 10.04 x64.
I used Code Blocks and I included the code blocks projects with a short guide to compile it for other versions.

You can get it here : http://www.foliativ.net/book/public/prog/cudafluidsolver/VHCudaSims_0.61.zip
It's not the latest version with the shadowed particles (http://www.vimeo.com/25279899), which requires some more cleaning and in which I think I broke cross platform compatibility.

Vincent

SGIFreak
07-23-2011, 08:10 AM
many thanks for your work

darkless0106
07-24-2011, 02:53 AM
I have just implemented the self shadowed particles sample from the cuda sdk, it's quite promising. Else I think I'll try to make the plug directly write a cache in the GTO file format (http://www.tweaksoftware.com/products/open-source-software) from which I have heard good things, as I'd like to keep the plugin the most application independant possible. Looks like it can be directly rendered with renderman, and there are example plugins for maya and houdini particles.

Vincent

hi I just use GTX275 win64

when I run initCuda() my Maya was crash.

I really don't know why.

Sickiziu
08-11-2011, 06:10 PM
is it possible to load the plugin in maya 2012 x64? i get the "// Error: The specified procedure could not be found. (VHFluidCuda11X64)" message when trying to load the plugin.
awesome work btw!

zp86
08-12-2011, 07:01 AM
thanks for your work,Vincent.
my card is GTX 260, maya 2011 64bit on windows vista 64.
every time i run initCuda(),maya just crash.
what kind of problem could it be?

Vinz9
08-12-2011, 08:42 AM
@ Sickiziu : it looks like you are missing some of necessaries dll (cudart, glew...)

@darkless106 and zp86 : initCuda should be run only once, if you run it more than once maya will crash. If it crashes right away, not sure why, the cuda/opengl interoperability is quite sensitive... Anyway it will be handled more elegantly in the next version.

Sickiziu
08-22-2011, 02:09 PM
i have latest cuda installed, im on maya 2012 hotfix 4 x64. the moment i try to load your plugin i get: "// Error: The specified procedure could not be found. (VHFluidCuda11X64)". That is before i run initCuda(), right?
are u certain it works with 2012?
thanks

Vinz9
08-22-2011, 08:35 PM
The maya version for which it works is the folder name in the archive, so for linux it's maya 2012 and it was compiled with cuda 4, for windows, it's maya 2011 and it was compiled with cuda 3.2. I know it's not very coherent but it's the versions I had when I compiled the plugin.

JohnPetrucci
08-23-2011, 12:57 AM
can anyone help me out here? I have installed everything, and loaded the plugin in maya,I create de initGLCuda node but after that I don't know what to do. I try loading the scripts but nothing happens.. I'm lost here.

lllcw
08-23-2011, 03:29 AM
Looks awesome!!! :bounce:

SGIFreak
08-23-2011, 06:25 PM
Hi Vinz9

Any particular date for new update? i will test in on maya 2012 on windows.

iTiunov
10-09-2011, 12:36 AM
Here is recompiled version for Maya 2012... Link (http://dl.dropbox.com/u/9315852/VHFluidCuda11X64.mll)

stooch
10-11-2011, 06:16 AM
Here is recompiled version for Maya 2012... Link (http://dl.dropbox.com/u/9315852/VHFluidCuda11X64.mll)

ne rabotayet :(

// Error: line 1: The specified module could not be found.
(VHFluidCuda11X64)

iTiunov
10-11-2011, 11:22 AM
I think that U need to install some additional libraries. They were discussed earlier in this thread.

P.S. It was compiled with CUDA 4.0...

republicavfx
10-14-2011, 02:29 AM
got the plugin installed on maya 2012, create fluid and run fluid3DSetup;...i see the custom AE and new CUDA objects in outliner and....crash...damn it...repeatedly

czaps
10-14-2011, 10:29 AM
I have the same results like blade33ru - maya crashes after displaying things in outliner and attributes editor....

iTiunov
10-19-2011, 03:58 PM
http://dl.dropbox.com/u/9315852/Fluids/fluid.jpg

monkey10120
12-20-2011, 01:40 AM
I installed the plugin. It starts fine when I type in initCuda() and it works. I just do not know what to do to get the fluid to use my gpu. Any help?

cgbeige
12-20-2011, 10:49 PM
looks great - any chance of a Mac build? Or if someone can tell me how to set up a compile, I can build and test it. I've got a Quadro 4000 Mac edition.

tozger
01-31-2012, 03:23 PM
plugins loads fine, init cuda creates the node and then what do we do?

fluid3DSetup(string $prefix)
fluid3DSetup
create fluid select it then run fluid3DSetup

doesnt work, what to do please help?

Reyan
02-23-2012, 01:45 AM
Hi guys,
Very interesting !!!
Can someone explain, how compile source code for Maya 2012 under Visual Studio 2008 ?
Because i have a lot of errors...

Thanks

CGTalk Moderation
02-23-2012, 01:45 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.