| Previous Topic (Fading Off Particle Density By Age) | Up (Contents) | Next Topic (Particle Color By Speed Using MAXScript) |
Particle Color By Speed Using Dataflow
Introduction
In this tutorial, we will take a look at controlling the color of the particles using a Particle Flow Toolbox #3 Data Operator from Orbaz Tech.
Data Operators allow you to create new operators by wiring a "Data Flow" out of so-called sub-operators which can read and write any particle channels and perform various mathematical operations on particle data.
You can download the 3ds Max 9 scene file.
Note that the PFlow Toolbox #3 plug-in must be installed in order to use this file!
The Particle Flow
The Particle Flow itself is very simple:
- A Birth Operator emits 1 million particles on frames 0 to 24.
- The particles are positioned in the volume of the icon which is set to sphere using a Position Icon operator.
- A Speed Operator in Along Icon Arrow mode with Inverted direction moves the particles up.
- A Force Operator applies a spherical gravity which has been animated to have a value of 1.0 on frames 0, 100 and 200 and a value of 0.0 on frames 50, 150 and 250. The Gravity has a Decay of 0.001
- The same Force operator applies a Drag force to slow down particles when no Gravity is applied.
- A Box #3 Data Operator reads the speed and sets the color (see below).
- A Display Operator set to Line mode shows the particles in the viewport.
The 3ds Max Scene
- In the 3ds Max viewport, clone the existing PF_Source01 Emitter 4 times - for example by rotating about the origin at 90 degrees. Notice that the PF Source will be cloned but the initial event will remain the same.
- The Gravity is placed exactly in the center between all 4 emitters.
Note that moving the Gravity away from the center can lead to very interesting variations of this scene - try playing with the settings, positions, number of emitters and so on to create new designs!
The Data Operator
The Data Operator implements a simple Speed Magnitude To Color conversion function:
- At the bottom of the flow, the sub-operator labeled "Vertex Color" is of Output Standard type. It can be used to write data to a particle channel. In this case, it has been switched to write to the Vertex Color Channel of the particle system and expects a Vector as input (symbolized by a magenta (V) connector).
- Above it, a Convert sub-operator turns three Real inputs (denoted by red (R) connector) into a single Vector output. The sub-operator's label reads "Real --> Vector".
- The first (R) input of the converter is connected to a Function sub-operator which performs a multiplication of its two Real inputs and outputs the result into the Red component of the final vector value to be written into the Vertex Color Channel. The function will multiply the Speed Magnitude of each particle with a constant scalar with a value of 50.
- The sub-operator labeled "Speed Magnitude" is of Standard Input type and can read any particle data channel. In this case, it has been switched to read the length of the Speed vector value.
- Since the speed magnitude is usually not large enough to produce a visible color, the Scalar sub-operator labeled "50" provides a multiplier to boost the speed value a bit before it is being written to the Red channel. Its output goes into the second (R) input of the Function sub-operator which performs the multiplication "R1*R2".
- Similarly, the Green channel is set by a Function sub-operator multiplying the Speed Magnitude value with a constant scalar of 30. This means that the value in the Red channel will grow faster than the one in the Green channel, thus resulting in a orange color when speed is high. If both scalars were equal, the color would be rather yellowish.
- Finally, the Blue channel uses the same basic setup as the Red color, but in addition it subtracts the result from a scalar with the value of 4.0. This means that as speed becomes higher, the blue channel will become less intense, while slow particles will be mostly blue - the exact opposite of the Red and Green channels.
Krakatoa Settings
We will render the particles using Additive Density because we are after a plasma-like effect.
- Use no lighting since we want a self-illuminated appearance.
- Set the Final Pass Density to Additive and the Density Per Particle to 1.0 / -3.
- To get a smooth result, check >Enable Motion Blur and >Jittered Motion Blur.
- Set the Motion Blur Segments to 8 and the Motion Blur Shutter (degs) to 360.0
- All other settings remain at defaults.
- Right-click the QUICK RENDER button and select Active Segment [0-250] Nth: 1
- Right-click the QUICK RENDER button again and pick Set Render Output Filename. Specify the desired location and file format (.EXR is recommended).
Finally, press the QUICK RENDER button to render the sequence.
Note that Krakatoa will use the Vertex Color Channel values of a Particle Flow if no material is assigned explicitly to the Flow using a Material operator. Alternatively, you could assign the vector calculated by the Data Operator to any of the other 99 mapping channels and use a Material with a Vertex Color Map pointing at that channel assigned to a Material Dynamic operator, but this setup would render slower because the material would have to be evaluated for each particle on each frame. Using the Vertex Color Channel directly, the Krakatoa particle color channel is set internally without the material evaluation overhead!
The Result
Below are selected frames and the full animation as QuickTime Movie. Each frame contains 4 million particles with 8 passes motion blue or 32 million point samples per frame.
Here is the final animation as Quicktime Movie (H.264 Codec, 1.3 MB)