PDA

View Full Version : Img Seq as 2D Fluid Emitter...


jeremyhardin
11-29-2006, 12:01 PM
So, I'm wanting to take my 2d fluid, use the paint fluids tool, then use an image sequence for an attribute map (rather than just a stationary image).

Is there some way to set the paint fluids tool to use an already loaded file, and one that is an image sequence? or should I look at object emmisions instead?

johner
11-29-2006, 08:40 PM
I don't think there's a way to do this without scripting. Duncan posted a way to do something like this on the HighEnd3d forum a while back. Basically you create a file texture that reads your image sequence, assign it to a nurbs plane or something to check and ensure it's loaded. Then create a script node that executes at time change and use code like the following:



//get the w,h resolution of the 2d fluid texture
int $w = `getAttr fluidShape1.resolutionW`;
int $h = `getAttr fluidShape1.resolutionH`;

//use colorAtPoint to sample the file texture at that res
float $colorVals[] = `colorAtPoint -o RGBA -su $w -sv $h file1`;

//scale alpha values by this
float $alphaScale = .25;
//scale RGB values by this
float $rgbScale = .1;

//loop through values and add to fluid texture
int $i,$j,$index=0;
for ($i=0; $i < $w; $i++)
{
for ($j=0; $j < $h; $j++)
{
//add alpha to density, RGB to color
setFluidAttr -at density -ad -xi $i -yi $j -fv ($colorVals[$index*4+3]*$alphaScale) fluidShape1;
setFluidAttr -at color -ad -xi $i -yi $j -vv ($colorVals[$index*4]*$rgbScale)
($colorVals[$index*4+1]*$rgbScale)
($colorVals[$index*4+2]*$rgbScale)
fluidShape1;
$index++;
}
}


This uses the -ad parameter to setFluidAttr, which adds the values at each time step, but you could omit it to set the color explicitly, for example.

Good luck

jeremyhardin
11-30-2006, 09:42 AM
brilliant, thanks. I'll give this a go.

*still getting the hang of writing my own mel, so this helps tremendously.*

jeremyhardin
11-30-2006, 04:35 PM
works exactly as expected. thanks again. :thumbsup:

jeremyhardin
11-30-2006, 06:23 PM
quick note to anyone else doing this...

I seemed to get a crash if I cached the fluids, then tried to render. removing the expression after caching seemed to fix it. so use the expression to cache, then use the cache in-scene and remove the expression.

CGTalk Moderation
11-30-2006, 06:23 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.