2009年11月9日

Introduction

The following example uses a real-world production scene from the movie G.I.Joe - Rise Of Cobra to demonstrate how Krakatoa and its MagmaFlow node-based editor can be used to work with and post-process particle data.

  • The 3ds Max scene contains a PRT Loader which is set to load one partition with slightly over 1 million particles.
  • The viewport display count is set to 1% and Load First N Particles which is the fastest loading mode. Loading Every Nth provides a better cross-section of the particle cloud, but is too slow for interactive tweaking because it requires the decompressing and scanning through the whole particle file instead of just its beginning.
  • The particles represent the processes in a futuristic missile warhead.
  • They have already been animated and colorized using Particle Flow and Box #3 Data Operators and cached to PRT files using Krakatoa.

Here are some representative frames from the sequence:

Culling The Particles By The Warhead Geometry

  • The particle cloud has been generated to be larger than the missile warhead containing it.
  • The warhead is transparent and we can see the particles swarming inside.
  • Instead of matting out the particles in post, we can easily cull any particles outside of the warhead using the Particle Culling feature of the PRT Loader.
  • We simply select the Culling Geometry (called HLP_Cull in the scene file) from the Select By Name dialog which opens via the Make Culling Named Sel. Set button in the PRT Loader's "Culling and Deformations" rollout.
  • A named selection set with the same name as the Culling Object will be created and the particles outside the volume will disappear.

Tweaking Particle Colors Using MagmaFlow

  • Using the MagmaFlow Editor, we can modify the existing and created new channels if necessary.
  • This approach is similar to changing colors in 2D post production, but it operates on 3D points in space and can thus affect the appearance of the final rendering in ways 2D compositing cannot (since it does not contain information about pixels behind other pixels).
  • Let's take a look at some of the many tweaks that could be performed using MagmaFlows.

Adding a Krakatoa Channels Modifier (KCM)

  • To add a KCM, we simply select the PRT Loader and press the KCM icon or use the Modifiers list and select "Krakatoa Channels".
  • The default flow in the KCM copies the Color channel into itself, so it does not change the appearance of the particles at all, but it is a great starting point for tweaking the Color channel:

  • We select the Color Channel Input Node and hit the * key on the Numeric Pad to insert a Multiply Operator, then we use the Ctrl+2 keys to create a Float Input with a value of 2.0. (Pressing the F key would create a Float Input with a default value of 1.0, but that would then require changing the value to actually see any changes, so we use the 2 key with Ctrl pressed instead):

  • This causes the particles in the viewport to glow brighter in green and yellow colors:

 Note that we are currently modifying 10% of all particles, or about 100,000 of them.
We could make the updates even faster by going down to 5 or even 1 % of the total particle count.

Animating The Multiplier Value

  • We can tweak the Float Input value to change the overall look of the particle, but since it is represented by its own Track with a Float Controller in TrackView, we could also keyframe the value to change over time.
    • We simply enable the Auto Key button in the 3ds Max UI and set keys as usual.
    • Scrubbing the Animation Slider back and forth will show that the particles are updating in nearly real time.
  • We can also use procedural animation on the Float Input track.
    • We press the Zoom In Track View button in the Float Input's Rollout and assign a Waveform controller to the selected Float track which controls the Float Input node in the MagmaFlow Editor.

  • In this example, we have two waves stacked additively to produce a more interesting effect:

Visualizing Particle Data As Color

  • Another useful application of the KCM and MagmaFlow features of Krakatoa is the visualization of data channels as Colors in the Viewport.
  • For example, the PRT Loader provides a line display to show the Velocity of the particles:

  • Using simple MagmaFlows, we could set the Color of the particles in the Viewport to represent either their velocity direction or their velocity Magnitude.
    • For example, simply adding a new KCM and changing the Color Channel Input to Velocity Channel Input will show the Velocity directions as colors:

  • If we wanted to show the Velocity Magnitude as color, we can
    • Insert the Magnitude Operator by selecting the Velocity Channel Node and pressing Ctrl+M
    • Insert a Blend Operator by pressing B
    • Press Ctrl+W to swap the Input sockets 1 and 2, then Shift+Ctrl+W to swap the Second and Third sockets of the Blend, since the Magnitude should go into the 3rd Socket.
    • Press Shift+1 to create a Vector Input Channel with the color RED connected to the first socket of the Blend
    • Press Shift+2 to create a Vector Input Channel with the color GREEN connected to the second socket of the Blend
    • And since the Magnitude is a lot above 1.0, we can select the Velocity Channel again and hit * and F to create a Multiply Operator with a Float Input, then we enter 0.012 into the Float Input to scale down the velocities.

  • If we intend to only visualize the Velocities in the Viewports but not render the Color channel, we can simply set the KCM to Off In Renderer to disable its evaluation at render time.

Modifying the Particle Color By Velocity At Render Time

  • Of course, we could use the above approach not only to visualize the particles in the viewport, but also to modify the existing colors based on the velocity of the particles.
  • All we have to do is reintroduce the original Color Channel loaded from the PRT file into the flow.
    • First we select the Blend Operator and press Shift+Ctrl+W to swap the second and third sockets, making the Velocity Magnitude the second socket.
    • Then we select Arithmetic from the Operator's Category list and select Multiply from the list of Arithmetic Operations - note that the second Vector Input does not appear to be connected to the Operator anymore, but in fact it still is, it is just being ignored. If we would switch back to a Blend Operator or another operator with three sockets, will will show up as connected again!
    • Now we select the first Vector Input node and switch it from Input to Channel and select "Color" as the source.
    • We can also change the Float input to 0.02 to increase the effect - as result, fast particles are now brighter green, but still use the same color loaded from the PRT sequence, just more intense.

  • Instead of using the Magnitude of the Velocity, we could use one of its axes - X, Y or Z - to modulate the color of the particles.
  • For example, if we want particles moving faster along the X axis to glow brighter than particles moving mostly along the Y and Z, we can make the following adjustments to the flow:
    • Select the Magnitude Operator, change to Conversion Category, ToScalar Operator.
    • Hit the 1 or F Key to create an Integer Input node with a default value of 1 (representing the X axis).
    • We can increase the Float Input's value to 0.05 to get better colors.
    • Since the Velocity X can be positive or negative, we could include the negative one by selecting the Velocity Channel and hitting the A key to add an AbsoluteValue Operator:

Exposing Controls To the Modifier Panel

  • If we intend to tweak this look of this setup, we could easily expose the Float Input and the Integer to the User Interface of the KCM to avoid dealing with the MagmaFlow itself.
    • We can select both Input nodes we want to expose and pick Expose>Expose Selected Inputs from the MagmaFlow Menus:

  • If we would rename the Input Nodes to "Scale Factor" and "Axis Index" respectively, the Exposed Controls in the KCM UI will also be renamed to show the artist using the controls what he is modifying:

Contrast By Velocity Instead Of Gain

  • With just a single change to this MagmaFlow, we could switch from changing the Gain of the Color to changing the Brightness/Contrast.
    • Select the Multiply Operator #4 and change the Operation Type from Multiply To Power.
    • Tweaking the Scale Factor now will change the particle color contrast:

  • Velocity X Axis Scale Factor of 0.01:

  • Velocity X Axis Scale Factor of 0.05:

  • Velocity X Axis Scale Factor of 0.5:

Modifying Velocity Channel

  • The Velocity if our particles represents where the particle would be on the next frame. Thus, rendering with a Motion Blur shutter of 1.0 would create a blurred particle along the vector displayed in the viewport.
  • Opening the Shutter wider than 180 or 360 degrees would result in an exaggerated motion blur effect, but it would also affect the Motion Blur of Matte Objects and would make it impossible to composite the particle rendering into the rest of the shot.
  • Using a simple MagmaFlow, we could multiply the existing Velocity Channel to get more blur without affecting the Matte Objects rendering.
  • All we have to do it add a new KCM, change the Color Input to Velocity, hit * for Multiply Operator, hit Ctrl+5 for a Float Input with default value of 5.0 and set the Output to Velocity.

  • No Velocity Scaling, Shutter 144.0 degrees:

  • Velocity Scaling 5.0, Shutter 144.0 degrees:

Deforming PRT Loader Particles

  • It is worth mentioning that particles can be deformed using almost all 3ds Max Gizmo-Based Deformation Modifiers, like Bend and Twist.
  • Let's apply a Twist Modifier to the PRT Loader and set the Angle value to 5000.0 degrees:

  • This is the result rendered with 8 passes Motion Blur. Notice that the Modifier not only changes the Positions but introduces new Velocities:

Acquiring Normals From Scene Geometry

  • The particle system used in this example was saved from Particle Flow without assigning a direction (Rotation or Spin) to the particles.
  • Krakatoa assumes the X axis of the Particle Flow particle to be its Normal vector and by default, all particles look along the world X with their local X.
  • Thus, if we would enable the Normal display in the PRT Loader, the particles will all point along the missile's X axis (sideways).
  • The PRT Loader provides the ability not only to cull particles, but also to acquire normals from the culling object.
  • All we have to do is check the Normals From Surface checkbox and enter a larger Culling Distance value (which defines the range from the surface normals will be affected). A value of 1000.0 should be safe enough.
  • Left: Original Normals along X. Right: Acquired Normals From Culling Geometry:

Pushing Particle Positions Along Normals Using Global Channel Overrides

  • We now have valid normal vectors on our particles, but the Culling is performed after the modifier stack has been processed and the particles have been transformed into World Space. Thus, a local KCM would not "see" the new normals.
  • We could resave the sequence with the new normals and use the new PRT sequence for our tests, but we have an alternative - the Global Channel Overrides in the Krakatoa UI provide the ability to apply MagmaFlows to ANY particles in the scene, even those not coming from PRT files. These include geometry vertices, Particle Flow Particles, Thinking Particles, Legacy 3ds Max Particles and so on.
  • Let's create a new Global Override Set and apply some position changes along the new Normals we just generated:
    • We open the Krakatoa GUI and expand the Global Render Values rollout.
    • We then press the Create New Global Channels Override Set - a new set called KCMOverrideSet01 will appear. It will have one default Color KCM automatically applied.
    • We change the Output node to Position Channel.
    • We change the Color Channel Input to Position Channel.
    • Then we hit the + key on the Numeric Pad to insert an Add Operator.
    • We press Shift+N to create a Normal Channel Input wired to the second socket of the Add Operator.
    • With the Normal channel selected, we press * to add a Multiply and hit Ctrl+4 to create a Float Input with value of 4.0
    • Then we select the Multiply Operator again and hit * once more time to insert another Multiply Operator.
    • We press the M key to add a new TextureMap Input Node.
    • We hit the 6 key to insert a Power operator (6 because it also contains the character ^ for Power)
    • We press Ctrl+3 to add a Float Input with value of 3.0
    • We select the Power operator and press Ctrl+M to insert a Magnitude Operator.
  • Now all that's left to do is pick a Texture Map to displace the particle positions along their Normals:
    • In the Map Input node, we use the Get Texture Map... button and pick a Cellular Map.
    • We open the 3ds Max Material Editor and select an empty slot.
    • We press the Put To Active MEditor Slot button in the Map Input node and now we can edit the Cellular Map - change the Size to 10.0 and copy black into the first division color.

  • No Push, Original Positions:

  • Push By Texture Along Acquired Normals:

Post a Comment:

留言會在通過機器人審核後才會顯示~留言完畢沒有顯示並不是留言失敗喔!

版權所有 © 2016 Jacys Lin All Rights Reserved. | 轉載請註明出處 |