Calculating Vertex Velocity
Currently, Genome does not expose a Vertex Velocity channel similar to the Velocity in Krakatoa PRT streams. The main reason is that the 3ds Max Modifiers have no concept of evaluation at a different time than the current and 3ds Max geometry does not support a dedicated Velocity channel.
Still, there are several ways to produce and use Vertex Velocity in Genome:
- Offset Animation - in some cases where the animation is keyframed and easy to shift in time, it would be enough to create a copy of the object and slide its keys by one frame to the right to produce the reference needed to calculate Velocity from the two sets of vertex positions.
- Offset Point Cache - another way would be to create a copy of the current object, bake all its deformations to a Point Cache modifier, disable all modifiers but the Point Cache and offset the timing by a frame. Then use Genome to read the Positions of the current and the cloned objects and calculate velocities based on the difference.
- Two Mesher Compound Objects - Attempting to use a single time-offset Mesher Compound does not work because it would create a circular dependency with the Genome modifier and the deforming object. But using two Meshers where the one provides the offset mesh and the other hosts the Genome modifier works.
- XMesh Cache - The Thinkbox XMesh geometry caching system generates a dedicated Velocity channel when saving, or can produce it from non-changing topology on the fly when loading if it was not saved. The XMesh Loader has an option to copy the Velocity to an arbitrary Mapping Channel, thus giving Genome direct access to that data.
- Frost Velocity To Mapping - In the special case of the Thinkbox Frost Particle Mesher object, the Velocity can be extracted from particles and copied into a Mapping Channel without saving to XMesh, allowing Genome to work with velocities from Frost directly.
- Save To PRT File - Similar to the example of baking Vertex Colors, a MAXScript could calculate the Velocities and bake them to a PRT file with one particle per vertex to sample later using Genome. This is a huge workaround and is mentioned here just because it is technically possible, but the above methods are generally easier to use.
In the following tutorial, we will take a look at some of these options.
Vertex Velocity From Offset Animation
Let's take a look at a very simple case to see how a cloned object with offset animation can be used to calculate Verrex Velocities. The same principle applies to using a Point Cached copy.
Velocity To Selection
- Create a Cylinder with Radius 15.0 and Height 100.0
- Increase the Height Segments to 20
- Add a Bend modifier and keyframe its Angle to 180.0 degrees on frame 100
- Change the Out Tangent of the first key on frame 0 to Slow
- Change the In Tangent of the last key on frame 100 to Slow
- Clone the whole object as Copy and place it on the side (it would be easier to leave it at the same position, but for illustration purposes let's offset it in space)
- Select the cloned object's keys in the TrackBar and shift them by one frame to the right so the animation starts a frame later.
- Add a Genome modifier to the first Cylinder and set it to "Vertices" iteration mode.
- Open the Editor and press Ctrl+[O] to create an Output node. Set it to Selection.
- Select the Output node again and press [O] and then [X] to create a VertexQuery operator.
- Drag a wire from the Geometry input socket to create an InputGeometry and pick the cloned object as the Geometry input.
- Drag a wire from the VertexIndex input socket to create and connect a VertexIndex InputChannel node.
- Select the VertexQuery node and press [T] and [P] to insert a Transform > ToSpace operator. Pick again the Cylinder002 copy as the reference object. This step is necessary because the VertexQuery reads in world space, but we want the Object Space position of the reference vertex.
- Select the ToSpace operator and press [-] to insert a Subtract operator to the flow.
- With the Subtract selected, press SHIFT+[P] to connect a Position InputChannel to the second socket. This produces the difference of the vertex positions of the two cylinders in object space.
- Select the Subtract operator again and press [V] and [M] to insert a Vector > Magnitude operator.
- With the Magnitude still selected, press [/] to insert a Divide operator.
- Press Ctrl+ to connect a Float InputValue with value of 1.0. We can use this divisor to scale down the speed if the vertices are moving too fast. Rename it to "Scale" and check the "Exposed" option.
RESULT: We now have a vertex selection based on the Velocity of the vertex. Move the time slider and watch the vertex soft selection changing color from blue to orange.
At this point, we could add modifiers that would affect the cylinder more when a vertex is moving than when it is not of they respect the soft selection channel.
Selection To Vertex Color
We could visualize the Vertex Velocities even better by converting the Vertex Selection to Vertex Colors:
- Add another Genome modifier and set it to "CUSTOM FACE VERTEX" iteration mode.
- Open the Editor and press Ctrl+[O] to create an Output node. Set it to Color if it is not set yet.
- Select the Output node and press SHIFT+[S] to create and connect a Selection InputChannel node.
- Press [C] and [V] to insert a ConvertTo > Vector operator.
- Right-click the object in the viewport and select Object Properties from the Quad Menu.
- Check "Display Vertex Colors" and "Shaded" and press OK to close the dialog.
RESULT: Moving the time slider will now reveal vertex colors based on the vertex selection.
On frame 50, we see that the velocities of the top vertices are too high and the color is cycling through black to red gradient more than twice (left image).
So we have to adjust the Divisor in the bottom Genome modifier to about 2.6 to get rid of this banding. (right image).
The alternative would be to clamp the Vertex Color values between 0 and 1, but this would mean that fast velocities above 1.0 units per frame would always have the same flat color.
Instead of using a Black to Red gradient, we can connect the Selection InputChannel to all three sockets of the ToVector operator to produce a grayscale gradient (left image), or replace the ToVector with the 3ColorGradient BLOP found in the Vector sub-category of the BLOP category (right image).
Two Mesher Compound Objects
A similar solution to the problem can be achieved using two Mesher Compond objects:
- Create a Mesher Comound object and pick the Cylinder as the object to mesh.
- Align the Mesher to the Cylinder, Pivot-to-Pivot.
- Clone the Mesher Compound object as Copy, leave aligned to the Cylinder.
- Offset the second Mesher by 1.0 frame.
- Add a Genome modifier in VERTEX mode to the first Mesher and create the following flow:
RESULT: We read the vertex positions in world space of both the original Cylinder and the second Mesher and calculate the selection which is assigned to the first Mesher.
The second Genome modifier described in the previous section could now be added to convert the Vertex Selection to Vertex Colors...