View Full Version : controlling goalPP with a map?
thematt 05-07-2007, 03:57 PM Hi guys,
I'm looking for a way to control the goalPP of my softbody with a map.I still can't beleive this is still complicated to do, all I'd need is to sample the color at witch the particles would be at, but i can't really get this to work.
Why alias or autosdesk haven't implement a fonction such as the "age" one that would let us simply apply a multiplier map based on the Uv of the object on any PP attributes.
I looked at goalU and goalV also at colorAtPoint, but I don't seems to be able to put those two together and make them work.I wish it was simper seriously.
If anyone know how to do it I would greatly appreciate.Like this or any other method ofcourse, probably there is a simple method that I'm overlooking.
thanks a lot guys.
cheers
|
|
pascal
05-07-2007, 05:32 PM
Hello,
I believe you should be able to do that, for a 2d map (-> not 3d noises, etc), using two scalar PP values (ie: goalPPU and goalPPV) and a arrayMapper.
Just create a new ramp for goalPP and use goalPPU/goalPPV for U and V.
Then reconnect your map to the arrayMapper just like the ramp.
Hope I'm clear...
And I will try it myself tonight just to be sure :)
Pascal.
thematt
05-07-2007, 09:36 PM
double post
thematt
05-07-2007, 09:37 PM
yep that seems intersting but not sure I understand what you mean sorry..
So you mean creating two new attribute floatPP i supposed that would have a map in their v and UPP attribute, then connect the goalPP to those attribute? is it what you're saying.iguess I should try then.
cheers
thematt
05-07-2007, 09:46 PM
The problem though is always the same, seems like it doesn't sample the texture at the exact uv the particles is at. If i assign a ramp and have the goalUPP driving the U and goalVPP driving the V, how do i tell the particles to sample the color at their exact position on the surface? that's my real problem actually.Meaning I should tell in an expression on the goalVPP and goalUPP to sample at that exact position the particles is at.
So far i had no luck doing that, should be quite straight forward, 'cause that so usefull.
anyway if you're techniques work I'd be so happy then, but I don't really get it I guess, or it's my expression that is restraining me.
thanks
matt
Meesto
05-08-2007, 12:14 AM
The MEL command `colorAtPoint` will allow you to sample a given map/shader without too much difficulty. Add something like this to your runtime expression:
float $gv = goalV; // This will keep your $goal command easier to read.
float $gu = goalU; // See above.
float $goal = `colorAtPoint -v $gv -u $gu -o A textureFileName`; // Sample the alpha of your fileTexture at the goalU and V.
goalPP = $goal; // Assign the sampled value to the goalPP.
What's going on is that you are using the current goalU and goalV of your given particle to sample the textureFile in question on your object. You will need to have UVs assigned to the object in question for this to work. The "-o A" flag tells colorAtPoint to sample only the alpha channel. So put your weights into your alpha channel. You can use this with any 2D texture. Obviously you need to replace the "textureFileName" with the actual file node name you are using.
You may also find that adding a clamp or remap is useful to adjust how the weights are interpreted (ie - clamp to a minimum of 0.1 and maximum of 0.9).
I hope this helps.
pascal
05-08-2007, 11:21 AM
Yes colorAtPoint is also a solution, but I believe it's a bit slower.
I have tested my method, it's working well on vector values ( like rgbPP ) but seems to have troubles with scalar values :(
Here is a sample scene, just go back to frame 1 and play, you will see that the color of the particles is taken from the noise... With an expression you can take one of the components and assign it to goalPP I guess... and use something else than rgbPP.
Pascal.
thematt
05-08-2007, 02:20 PM
thanks both for your answers..will check that out.
cheers
thematt
05-08-2007, 09:22 PM
Ok so I'm having no luck with either one of the solution.
Pascal, looking at the scene I see that this work but it's because you used an emiter surface, and had assing a parentU V at your emiter.This is the same actually as using the inherit color at the bottom of the emitter, and yes that is working fine, but I need that on a softbody and it's totally different..or maybe I'm simply missing something obvious again and in that case sorry.:blush:
But thanks for that anyway if you have other ideas please don't hesitate.
Meesto, the technique you describe is actually what I was trying at first without luck, the problem I have is as soon as I assign a goalU and V to my softbody those particles won't stick to the coresponding vertex and they all snap at the vertex that is at 0 0 of the UV. this doesn't help much then as I don't really understand how to control their position anymore actually.
Seriously it's a pain in the a## to do such a simple thing too bad really as it could be extremelly helpfull in many case.
thanks a lot guys.
cheers
pascal
05-09-2007, 08:55 AM
Hello again,
The method I have described is not just inherit color :)
I've used a surface and parentV parentU just for the simplicity of the setup and an easy way to check the result ( a bunch of numbers is much less readable than the colors )
parentU/parentV can be any other scalar PPattr, and you can give them any value you want. It's actually the location on the texture but expressed in U/V instead of pixels.
rgbPP can be any other vector PPattr.
Now, I've tried to assign the output to testVector and added an expression to assign the result to rgbPP on creation (just to help me check the result), and while it is working, the particles are black at for on frame at birth...
So there might be some potential trouble to investigate :)
If you need that in simpler way you can check some other solutions, commercial ones like stroika (http://www.kolektiv.com, but it does a lot more things) or a free one on highend3d http://www.highend3d.com/maya/downloads/plugins/dynamics/solidTexSampler-906.html
(you might have to recompile it for more recent versions of maya )
It's indeed a lot of hassle for such a simple thing :)
Pascal.
I've only skimmed the posts here, so forgive if I miss out on something...
I think essentially the issue here is, that the particles in a softbody are not goaled in the same manner as when just selecting a goal for particles... the particles in a softbody are not aware of their goals by UV coordinates, but rather just to the vertices of the goal mesh.
So it's no use to ask them of their parent UV's or goal UV's.
However, you can query the vertices of the non-soft (goal) mesh, ask for their UV coordinates, and use those coordinates for your softbody particles in conjunction with a colorAtPoint command....
The particleId numbers of the softbody matches the vertex numbers of the mesh. Take a look at the expression below. I put it in the creation expression of the softbody particles. As it's a particle expression it goes through every particle, one by one, ask's for the particles Id number, selects a vertex with the same number, and queries it's UV position. Then ask's for the color of a ramp, at the specified UV coord's. Converts the RGB info to HSV, and sets the goalPP to equal the V component of HSV.
int $pId = solidParticleShape.particleId;
select -r copyOfsolid.vtx[$pId];
PolySelectConvert 4;
float $uvPos[] = `polyEditUV -q`;
vector $color = ` colorAtPoint -o RGB -u ($uvPos[0]) -v ($uvPos[1]) ramp1`;
vector $hsv = rgb_to_hsv($color);
solidParticleShape.goalPP = $hsv.z;
If you need to animate the goalPP by sampling colors from a file sequence, you would need to have these expressions in runtime too. Get's very slow though!
Wondering... maybe it was mentioned already... but why not just paint the softbody goal weights? If you don't need animation on the weights that is.
Cheers.
thematt
05-09-2007, 09:31 PM
Pascal thanks man..:) sorry I didn't say your workflow was the same as the inherit color, but simply that the result of inherit color will give me the same thing with the emit from object.
Ctp, you've hit the nail buddy..wil lcheck the expression out but the solution looks good, it simply that I'm always scare to put mel command in my expression, although it's good sometime, here is a prime exemple.
I know I could paint weight, but simply I need to do many test, with different map some of them are aniamated and it would be to paint them all the time.Plus this as always intrigate me and was wondering why I couldn't come up with a solution.
anyway thanks guys for the great help.
cheers
CGTalk Moderation
05-09-2007, 09:31 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.