Genome And Field Intergration

Applicable to Stoke MX 2, Last Edited June 3, 2014

Overview

The Genome modifier, previously available as a separate 3ds Max plugin product, is now an integral part of the Stoke MX 2 package. In addition to several loop-related improvements, the Genome modifier in Stoke MX 2 also features a dedicated InputField operator that allows direct access to any Stoke Field object data from a Genome modifier.

In the following tutorial, we will use the Simple Plume data generated in the previous tutorial to affect a mesh object in various ways via a Genome modifier.

The Base Setup

  • Use the same 3ds Max scene and Field data as in the previous tutorial.
  • Delete the Stoke Particle Simulator object as we only require the Stoke Field Simulator.
  • Create a new GeoSphere primitive with Radius 50, Segments 16 at Position [40,0,80].
  • Select the Stoke Field Sim object, check the On checkbox under Viewport Display to show samples in the views.
  • Switch the Mask drop-down list to Density - this will limit the display of samples to only positive Density values where the smoke is.
  • Switch the Color drop-down list to Density - this will display the Density values as grayscale values.

RESULT: The GeoSphere will slightly intersect with the plume after Frame 25 (the following image is from Frame 65):

../../_images/STK2_GenomeAndField_BaseScene.png

Deforming Mesh By Velocity

In the following example, we will shift the Position of the GeoSphere’s Vertices by the value of the Velocity field at the Vertex’ Position.

  • Select the GeoSphere
  • In the Modify Panel, add a Genome modifier. Keep all settings at defaults, Iterate over mode should be Vertices.
  • Click the Open Magma Editor button.
  • Press CTRL+R to enable Auto-Reorder mode.
  • Press SHIFT+CTRL+P to add a new Position Output node.
  • Press SHIFT+P to create and connect a new Position InputChannel node.
  • With the Position InputChannel still selected, press the + key on the Numeric Keypad to insert an Add operartor.
  • Click with the mouse on the second input socket of the Add operator and drag while holding the left mouse button, then release over an empty area of the Editor to open the create node menu.
  • Select Input > InputField from the menu - it will be created and connected to the Add operator.
  • Drag from the Position input socket of the InputField to the Position output socket of the InputChannel Position node to connect them.
  • Since the InputField Position expects a World Space value, but the Genome Position is always in Object Space, we must convert the value ToWorld - select the wire connecting the InputChannel Position and the InputField, and press T for Transform and then R for ToWorld.
  • Select the InputField node, click the Pick Field Object… button and pick the Stoke Field Sim object from the scene.
  • Drag with the mouse from the Velocity output socket of the InputField object and connect into the second socket of the Add operator to replace the existing connection with the Color output socket.
  • Select the wire connecting the Velocity and the Add operator and press the / key on the Numeric Keypad to insert a Divide operator.
  • Press CTRL+5 to create an InputValue Float connected to the second socket of the Divide operator. The Velocity Magnitude will be reduced 5 times - it is stored in Generic Units PER SECOND, and without a divisor it would distort the mesh too extremely!
  • Check the >AUTO checkbutton to enable automatic updates.
../../_images/STK2_GenomeAndField_MoveByVelocity_Magma.png

RESULT: The GeoSphere will be distorted by the Velocity field, but too extremely!

../../_images/STK2_GenomeAndField_MoveByVelocity.png

Here is the whole animation, with Viewport Reduction forced to 1 to reveal more detail in the displacement:

../../_images/STK2_GenomeAndFields_Displace.gif

Modulating The Displacement By Density

Right now, all vertices are being displaced by the Velocity Field, even where there is no Smoke to interact with the mesh.

We can modulate the effect by using the Density channel as a multiplier.

  • Select the Divide operator and press * on the Numeric Keypad to insert a Multiply operator.
  • Connect the Density output of the InputField to the second socket of the new Multiply operator.
  • Select the new wire between the two operators and press F for Function and then C for Clamp to insert a Clamp operator. It defaults to Min 0.0 and Max 1.0 which is exactly what we want - Smoke values between 0.0 and 1.0 will be preserved, all other values will be clampled to that range.
../../_images/STK2_GenomeAndField_ModulateByDensity_Magma.png

RESULT: The Displacement by Velocity will now be performed only where the Density has positive values.

../../_images/STK2_GenomeAndField_ModulateByDensity.png

Selecting Vertices By Density

Let’s say we want to smooth out the Velocity Displacement effect we just produced by Relaxing the mesh.

  • Add a Relax modifier to the GeoSphere above the Genome modifier.
  • Enter 10 iterations.

RESULT: The whole GeoSphere is now relaxed. While the displaced area is nicely smoothed, the rest of the GeoSphere loses volume.

../../_images/STK2_GenomeAndField_RelaxWhole.png

We can apply the Relax selectively by providing a Vertex Soft-Selection with the Genome modifier based on the Field values.

  • Click in the Magma Editor to get it into focus, then press SHIFT+CTRL+S to add a Selection Output node.
  • Drag a connection from the Density output of the InputField operator to the new Selection Output.
../../_images/STK2_GenomeAndField_Selection_Magma.png

RESULT: Only the selected vertices will be Relaxed, the rest of the GeoSphere remains untouched:

../../_images/STK2_GenomeAndField_RelaxSelection.png

Here is the whole animation with the object deselected to hide the vertex soft-selection. You can also add a TurnToMesh modifier set to Object level to suppress the selection display when the object is selected:

../../_images/STK2_GenomeAndFields_Relax.gif

Further Considerations

While we demonstrated the integration of the Genome modifier with a Stoke Field Simulator object, we can easily apply the same principle to any Fields from any supported sources. For example, you could pick a Stoke Field Loader with any supported data, a FumeFX Simulation object, or even just an FXD sequence as an Override in the InputField, and you will be able to apply the same approaches described above.