colorAtPoint for fluid emission rate


#1

Hello guys,
i’m quite new to MEL, but i’m trying my best (not too much luck at the moment) to get the emission rate of my fluid be driven by an expression:
I’m trying to emit a random value (fluidEmitter1.rate = rand(150,250) when the UV values on my surface are higher than 0, I can’t really get how to calculate the UV values using the colorAtPoint, can someone help please?
This is the idea i came up, obviously not working!

if (float $tempA[] = 'colorAtPoint -o RGB -u 0.0 -v 0.0 checker_1)
fluidEmitter1.rate = rand(150,200);
}else{
fluidEmitter1.rate = 0;
{

cheers!
G


#2

Couldn’t you use an emission map? That allows you to control emission based on UV’s via a texture. And you can drop in your rand expression in the emission value.


#3

The only problem with the emission map is that i’m gonna use a script to run it as well! I will use it but i like to have full control on it!
at the moment i got to fix the first expression using the following script!

int $numUVs[] = polyEvaluate -uv pSphere1;
float $tempRGB[] = colorAtPoint -o RGB -u 439 -v 439 noise2;
$RGB = $tempRGB[0]*time;
if ($RGB < 0.1)

    fluidEmitter2.fluidDensityEmission = 0.2;

else if ($RGB < 0.4)
fluidEmitter2.fluidDensityEmission = 0.6;
else
fluidEmitter2.fluidDensityEmission = 0.1;
but now that i’m working on the emission map density i have some new problems :banghead:
whenever i run this script maya freezes :frowning:

int $i = select ("pSphere1.vtx[300:330]") ;
int $l = select ("pSphere1.vtx[3:33]") ;
int $t = currentFrame ;
if ($t > 50)
fluidEmitter2.densityEmissionMap = $i;
else
fluidEmitter2.densityEmissionMap = $l;

any help is very well appreciated guys!

Cheers :wink:


#4

The fluid emission mapping doesn’t work the way you think. Your expression is evaluated outside of the inner loop that walks the faces of the mesh, emitting fluid. The map connections on the fluid emitter expect a 2d texture and internal to the emitter call they set uvs and evaluate the 2d texture at those uvs… you can’t insert an expression inside that loop.

However you can instead map the emission using a fluidTexture2D. If desired you can use emitters to emit into this texture or use its attributes like fuel to do things like burn propagation.

Or instead if you want full expression control you can make the fluidTexture2d just a grid that you set values on from your expression (solver = None, velocity = Off).
Your expression would need to walk the 2d fluid array setting values using setFluidAttr.

Or perhaps simpler might be to directly set voxel values on the 3D fluid and not even have an emitter. You can get the location of a fluid voxel at a 3D point in space using fluidVoxelInfo, then use setFluidAttr with the resulting voxel id.

Yet another method might be to use particles… you can emit particles from a surface, then emit from the particles into the fluid. One could then use a particle expression to kill particles where you don’t want any emission.


#5

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.