PDA

View Full Version : Output Fluid Velocity to a Texture Map


rgkovach123
06-07-2012, 04:59 PM
So i was looking over some GDC slides and I came across the Naughty Dog talk about Flow Maps and how they used Fluids in Maya, specifically the Paint Fluid Velocity tool.

In the talk it is mentioned that a script was written to output the Velocity Vectors as Red and Green values in a texture map.

I'm looking for a hint to where I can find these velocity vectors. I've been digging through the attrs on fluid shapes and combing through maya ascii files to figure out where these values are stored...

rgkovach123
06-07-2012, 06:29 PM
I found the data i was looking for, it's stored as a list of tuples on the attr:
fieldData.fieldDataVelocity

azshall
08-31-2012, 05:54 PM
How were you able to write out this data to a flow map?

rgkovach123
08-31-2012, 06:18 PM
i used the Python Image Library to output the texture map.

the process is pretty simple actually, just need to convert each velocity vector into a RGB value.

the only stumbling block i encoutered was the velocity data is read from the lower -left hand corner and PIL write pixels from the upper-left, so i just had to perform a vertical flip of the image data before writing it out to disk.

a couple of downsides to this approach
one is that you are painting arrows, not colors, so you kinda have to zoom in close to see the arrows clearly. even though fluid fields have options to display fewer arrows, when you start painting velocity, all of them are drawn.

secondly, maya's performance suffers dramatically if you try to paint velocity fields with greater than 256 x256 resolution.

luckily for me, i don't need really high resolution flow maps. i can get away with a 256x256 image.

Aikiman
09-03-2012, 02:14 AM
With SOuP you can connect outVelocityPV into inRgbPV of its fluidEmitter to emit straight into a fluid 2D texture if desired.

rgkovach123
09-04-2012, 02:57 PM
that is awesome! I need to look into that!

Aikiman
09-04-2012, 10:21 PM
If you have any questions just hola.

rgkovach123
09-04-2012, 11:03 PM
thanks! nice blog!

Aikiman
09-05-2012, 09:40 AM
Thanks a lot.

epithius
09-06-2012, 09:47 PM
Hi Aikman,

Can you provide some more specific steps on connecting those together? I am very new to soup, so pardon my being naive. I see OutVelocityPV with the fluidAttributeToArray node, but I can't seem to find the attribute on the fluid to connect it to. And I'm trying to use the handy connect option on the shelf, but that's always empty. I'm not sure what expressions in the hypershade I should be highlighting.

You say connect it to the emitter, or the fluid volume? Any help is greatly appreciated.

Aikiman
09-06-2012, 11:48 PM
Hey no worries, what you do is connect the fluidAttrToArray into a pointCloudFluidEmitter and connect the emitter to a fluid2Dtexture.

The connections are like this...

fluidAttrToArray.outDensityPV > pointCloudFluidEmitter.inRatePP
fluidAttrToArray.outPositionPV > pointCloudFluidEmitter.inPositionPP
fluidAttrToArray.outVelocityPV > pointCloudFluidEmitter.inRgbPP

Just shift the fluidTexture into the fuildShape. You can slide it along to get a slice of voxels you want.

Then I thought it would be better if instead of connecting...
fluidAttrToArray.outDensityPV > pointCloudFluidEmitter.inRatePP

You did this instead...Grab the magnitude of the fluidAttrToArray.outVelocityPV and piped that into pointCloudFluidEmitter.inRatePP that way you dont rely of the density but rather velocityPV to emit density into the texture fluid. You can use the point node to work out the magnitude and pipe that into inRatePP but it is quite a bit slower to work.

If you have problems lemme know.

BTW Im not sure if this is standard but where the values of velocity are in the negative Y or X ( 2D texture) the rgb values will be black obviously. I havent really looked into this yet but a SOuP remap node may work here or just remap the values in the point node.

CGTalk Moderation
09-06-2012, 11:48 PM
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.