new fluid sim adventures

gtoledo3's picture

I've been experimenting the concept of using motion vector fields to create dynamic lighting on the fly, in a an efficient way that makes use of parallel processing and image products that are typically generated when doing fluid sim.

With a fluid sim, or other things that you can analyze motion vectors from, it's conceivable to create an image output that shows the motion vectors, and using OpenCL, it's reasonable to get it going at a fairly high resolution in QC and still be speedy. By using a byproduct of the motion vectors at various points in the chain along with modification to those outputs, one can create different styles of, perhaps "over-hyped" but dramatic, normal maps that influences lighting.

By using the divergence, I'm finding that one tends to get a lighting look that reflects the surface of water, while also revealing stuff underneath. That's what gives the look of the darker, wetter looking parts of this clip.

By using the straight up motion vectors, the lighting tends to feel more integrated into the sim, without a surface tension thing going on. With muted light settings, it can look a bit cloudy, though can also look really wet when the ambient, specular, and main lighting settings are tweaked just so.

What I'm finding most novel out of it is the lighting method of normals being generated from motion, and that it works, looks cool, and doesn't add much more processing toll. The result feels like a hi-fi look for QC.

I'm outputting the liquid sim to cwright's normal map demo qtz 1 glsl shader, which is built to receive texture and normal map, to create the lit look. I'm also using Stoney Ballard's image to force as an easy way to get the motion going for the fluid sim... it's also pretty cool using the schema apple did for their wind tunnel to generate force.

I'm going to post this soon after I edit it some more, and add notes.

gtoledo3's picture
Re: new fluid sim adventures

This is the composition (well, I also added some stuff that isn't in the clip).

There are three modes that send differing textures to the GLSL shader for normal map calculation; one that uses the vectors, one that uses a kind of normalized vector interpretation with additional gain parameters, and one that uses divergence texture.

There's a mode for triggering MacCormack advection scheme as well, which adds a bit more accurate calculation (arguably?) to the simulation.

This uses OpenCL, and has only been tested in Snow Leopard 10.6.7 10J869 with the nVidia 9600.

PreviewAttachmentSize
Fluid 103.qtz83.45 KB

cybero's picture
Re: new fluid sim adventures

works for me in SL [10.6.7 / 10J869] &L [10.7 / 11A419] on my nVidia 9400, the fps is very much affected by the speed of the fluid movement, the faster the fluid, the faster the fps [IMETD].

gtoledo3's picture
Re: new fluid sim adventures

Woah, no kidding! I hadn't even thought to measure speed of sim / fps, I'd mainly looked at the quality setting and fps.

On my end, I don't really get a measurable fps hit when I change to MacCormack advection, which is surprising to me. It's a whole other ball of wax to throw into the process.

gtoledo3's picture
Re: new fluid sim adventures

I made a another little clip that shows the MacCormack advection setting. I'm basically writing at a low speed on the simulation, then I crank the speed.

psonice's picture
Re: new fluid sim adventures

I like that!

gtoledo3's picture
Re: new fluid sim adventures

Thanks man!

The thing that I've never personally read about before and that was a happy revelation from working it over, is that the divergence in a fluid sim seems to basically represent the surface tension, or ripple effect, but also carries info about the main texture as well.

So, if the normal map is made from the Divergence instead of from the main texture or from the motion vector (I'd been using motion vector previously), there's a distinct impression of a surface, as well as "stuff going on" below the surface. The result is a super wet/organic look.

If I use the motion vector, or manipulated motion vector for normal generation, the final look of the normals is more integrated into the main mass of movement.... which is a good look as well.

This below uses the manipulated motion vectors instead of the divergence.