How to fade particle instancer
(Maya Dynamics Tutorial)
In this tutorial i`ll try to explain how to fade particle instances on a particle basis :). So, here we go :
Duplicate the object which you intend to use as instance 10 times for this example. The number of duplicates are actually steps of fading.
After that duplicate the shader of the object 10 time as well and lower the transparency on every shader 10% lower then the previous one. After that assign the shaders to objects like in the screen shot below.
Create the particle object and prepare it for instancer. Having to make this basic routine every time is boring, therefore i`m using couple of lines of MEL code to add custom attributes and write some basic creation and run-time expression. So here is the code, just select your particle shape and run it.
string $objs[] = `ls -sl -type "particle"`;
string $obj = $objs[0];
addAttr -ln x_indexPP -keyable true -dt doubleArray $obj;
addAttr -ln x_indexPP0 -keyable true -dt doubleArray $obj;
addAttr -ln x_scalePP -keyable true -dt vectorArray $obj;
addAttr -ln x_scalePP0 -keyable true -dt vectorArray $obj;
addAttr -ln x_rotPP -keyable true -dt vectorArray $obj;
addAttr -ln x_rotPP0 -keyable true -dt vectorArray $obj;
setAttr ( $obj + ".lifespanMode") 3;
string $creationExp = `dynExpression -q -c $obj`;
string $runttimeExp = `dynExpression -q -rbd $obj`;
$creationExp = "\\r\\nx_indexPP = (int)rand( 0, 9 );\\r\\n\\r\\nx_scalePP = rand( 0.5, 0.8 );\\r\\n\\r\\nx_rotPP = rand( 360 );\\r\\n\\r\\nlifespanPP = rand( 3, 5 );\\r\\n\\r";
$runttimeExp = "\\r\\nx_rotPP += << rand(10), rand(10), rand(10) >>;\\r\\n\\r";
dynExpression -s $creationExp -c $obj;
dynExpression -s $runttimeExp -rbd $obj;
Open creation expression and replace the row which set the x_indexPP attribute with x_indexPP = 0; This will ensure all particles have no transparency at birth. Then select all 10 objects and create the instancer.
(make sure the instancer attributes are set like in the below screen shot so the custom attributes will be used)
If you hit play you`ll get something like this:
(in this example i have keyed emitter emission rate at frame 0 with value 20 and at frame 20 with value 0 with stepped keys, just to keep the scene readable)
Now I`ll make two new custom attributes:
First attribute is named x_dieAt (be careful this is NOT a PP attribute) and represents a percent value (take values between 0-100) of the lifespanPP, value at which i want my particle to start fading.
Second attribute is x_dieAtPP, which is the calculated value at which each particle i want to start fade, and i`m using it because i have different lifespanPP for every particle.
Next, in the creation expression add the line which calculate x_dieAtPP for every particle.
Now let`s start dealing with run-time expression. This is pretty simply, but a good understanding of the linstep function is needed. Below is the code i`m using to make my particle switch to the next object.
(which is the next step in transparency)
This is it! Hope i have made this very clear and easy to follow.
Alin Sfetcu - VFX Artist
aSfetcu (at) gmail.com
Author: Alin Sfetcu
Submitted: 2006-05-06 00:18:17 UTC
Tags: script, instance, particle, fade, and mel
Software: Maya
Views: 69,735
Related Items
-
Diesel Particle Filtering 3D Model
$55.00 (USD) -
Sun - Particle Flow 3D Model
$50.00 (USD) -
Waveform Motivator for Maya 1.0.0 (maya script)
$30.00 (USD) -
Sofia 3D Model
$120.00 (USD) -
Falling Snow Animation 3D Model
$20.00 (USD) -
Hand-Held Detector 3D Model
$39.00 (USD) -
FULL - 130 scripts for Modeling,UV + video tutorials for each 1.1.0 for Maya (maya script)
$40.00 (USD) -
Mass Instancer for Maya 1.6.0 (maya plugin)
$299.00 (USD) -
Merge Meshes 1.0.0 for Maya (maya script)
$20.00 (USD)