View Full Version : How to do random particle instance scale
09-22-2009, 06:31 PM
I've been trying to figure this out and I can't find anything on google about it. But. I have some objects instanced onto particles and I was wondering how one would randomize the scale. In the particle shape under general I see a scale drop down but I don't know how to access that with expressions or which drop down selection to use...
Any help would be great. Thanks
09-22-2009, 07:51 PM
Create a new Per-Particle attribute on the particle shape named 'scalePP' or something similar. Make sure in the Add Attributes dialog that its of type "vector" and the "Per-Particle" attributes are selected. Right click on this new attr in the particle shape's node Per-Particle Attributes section and go to the 'Creation Expression'. You can use the following lines of code for the expression:
//for non-uniform scaling of the axes
vector $scale = sphrand(1);
//for uniform scale of the axes
//vector $scale = rand(1);
//assign the scale vector to the per-particle attr
scalePP = $scale;
Now in the Instancer section of the particle shape node set Scale to scalePP and then the instancer will use that attributes for scaling the instanced particles. You may have to enable 'Allow all data types' for scalePP to show up in the Scale drop down list.
09-22-2009, 08:09 PM
I kind of just did something like this. I'm not used to making attributes for dynamics so I did a .mass = rand ... and then selected mass under the drop down.. haha. seems to work but your way is much cleaner. Ill test it out. thanks!
09-22-2009, 08:30 PM
That would work too, however if you apply any Fields / Forces to the particles they will behave differently being that Force = mass * acceleration. Just something to be aware of.
09-22-2009, 08:34 PM
right.. I just tested your method out and it works great. thanks.
why only have rand(1) ... I only know about doing 2 numbers... what does 1 number do?
09-22-2009, 08:43 PM
Its more of just a personal programming preference. I believe its the same as rand(), but it just tells me when I look at the code that it will create a random number between 0 and 1.
Not to mention, if you wanted the scale of the particles to be generated with a larger scale such as 2 you could just use rand(2). This would make the largest scale of the particles 2 and the smallest scale to be 0.
09-22-2009, 08:43 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.