| Previous Topic (Introductory Tutorials) | Up (Tutorials) | Next Topic (MagmaFlow Practical Example GIJoe) |
Introduction to MagmaFlow
Available in Krakatoa v1.5.0 and higher
The MagmaFlow Editor, introduced in Krakatoa 1.5.0, provides a node-based environment for particle channel manipulation and creation.
The following introduction should give you the basic knowledge of some typical workflows and capabilities of this system.
Creating a Base Scene
- Let's create a very simple setup:
- Create a Teapot with Radius of 30 around the origin of the world
- Select the Teapot and click the GEO icon on the Krakatoa toolbar (if you have customized one). Alternatively, go to Create tab of the Command Panel, select Geometry, Krakatoa category and create a PRT Volume object. Pick the Teapot as the Volume Object.
- Disable the Viewport > Spacing checkbox - the spacing in the Viewport and in the Renderer will be now 1.0, resulting in 84,801 particles.
- Hide the original Teapot.
- If you used the GEO icon, the PRT Volume will have the same object color as the Teapot. Otherwise the object color will be some random color, and all particles will display in the object color because there is no other color source yet.
Creating a Krakatoa Channels Modifier
- The MagmaFlow editor is currently available only through the Krakatoa Channels Modifier (KCM). Let's add one to see how it works.
- Select the PRT Volume object and click the KCM icon on the Krakatoa toolbar (if you have it customized). Alternatively, go to the Modify panel and select Krakatoa Channels from the list of modifiers to add.
- RESULT The particles will turn black. This is because the PRT Volume has attempted to acquire the Color Channel from the Teapot but there was no such channel in it. The KCM tries to read the Color channel and set the Color channel to the same value, and it all ends up with a value of [0,0,0].
Opening the MagmaFlow Editor
- With the Krakatoa Channels modifier selected on the stack, press the Open MagmaFlow Editor... button in the modifier's UI.
- The Editor will look approximately like this:
First Look Around
- Let's take a look at what is in the Editor:
- The main part of the window is the editing area where you can see two connected nodes.
- The green node in the upper right corner is the Output node. It is labeled "1 OUT:Color / float16[3]". The Output is always the first node in the flow, it cannot be created or deleted. It is currently set to output to the Color channel in Floating Point format with three components, each one with 16 bit data width.
- The white node is currently selected. If you click the editing area outside of the node, it will become deselected and you will see that it is actually blue. All Channel Input Nodes are blue and are used to read data from existing particle data channels. This one is labeled "2 IN:Channel:Color / Color float16[3]" which means that it is reading the Color channel of the particles in Floating Point format with 16 bit data width and 3 components.
- The Input node has its output socket (circular) connected with an arrow to the input socket (rectangular) of the Output node. This is about the simplest flow possible and currently does nothing, since the data from a channel is copied into itself.
- At the bottom of the editor you would see some gray round buttons - these are the category headers of the Node Depot. Clicking any of them will open a column of colorful buttons, each standing for a node. Clicking at the category header again will close the group again. We will look at these later.
- At the right side of the Editor, you will see a vertical Command Panel similar to the one found in 3ds Max and in Particle Flow. Relevant rollouts will be shown there depending on the current editor selection. When the Input Channel Node is selected, we can see the Input Type being Channel and the Channel Name being Color, plus some relevant info about what the Channel is used for and that it will be considered by the PCache when rendering.
- The main part of the window is the editing area where you can see two connected nodes.
- In the bottom right corner you will find some navigation icons and the Undo and Redo buttons. We will deal with these later.
Editing the Flow - Normals To Color
- Let's change the flow to do something useful. For example, since the PRT Volume not only creates particles but also captures some existing channels from the Volume Geometry, let's take a look at the Normal channel and represent it as color in the viewport!
- To do this, select the node "2 IN:Channel:Color" and in the Command Panel, change the Channel Name drop-down list from "Color" to "Normal".
- RESULT: Now the node's label reads "2 IN:Channel:Normal" and the particles in the scene look like this:
Position To Color And Adding Nodes
- Now this is rather useful - we could easily render a normals pass using this color.
- Let's change the Input Node once again, this time to Position.
- With the Input node still selected, scroll up the Channel Name list and select Position.
- RESULT: The particle colors are now based on the object space positions of the particles and are mostly blueish, because the Z component is positive everywhere and thus dominant. You can see the 4 quadrants where the X and Y change from negative to positive values.
Auto-Reodering The Flow
- Before going on, let's enable the Auto-Reordering feature of the Editor.
- In the View menu, select Auto-Reorder - Toggle to check it. The Input node will move closer to the Output node. There are multiple ordering patterns, the default is the Row Pattern - these can be selected from the View>Reorder Patterns menu.
Scaling The Position Channel
- In order to make the color values represent the actual position values better, we should scale the position channel data down a lot. This is because Krakatoa and MagmaFlow consider the vector value [1,1,1] to be pure white, but our teapot is about 60 units in diameter, so only particles around the origin between [-1,-1,-1] and [1,1,1] can be represented as useful colors, all other values above them are clamped and appear solid.
- Let's multiply the Position Channel Input node by a small floating point value, like 0.03 for example.
- To do this, we will use the keyboard shortcuts of the MagmaFlow Editor which are arguably the fastest way to work with it:
- Make sure the Input node is still selected, then hit the large * key on the Numeric Pad of your keyboard.
- RESULT: This will create a new selected Multiply Operator node to the flow, connecting the Input node to one of its two sockets, and inserting it into the existing flow so that its output socket is connected to the input sockets of the Output node. You might notice an ERROR message at the bottom of the Editor - this is because the second socket of the Operator is unconnected and thus the flow is in an invalid state. If the AUTO button in the upper right corner is checked, the flow will be sent to the KCM modifier every time it is changed in some way, causing the compiler to attempt to convert the flow into usable code, and reporting possible errors in the process.
Adding A Float Input
- To fix the error, we will have to connect another node to the second socket of the Multiply Operator.
- We want a Float Input node, so you should hit the F key
- RESULT: A new Input Node will be added to the flow and will be connected automatically to the Multiply Operator which was left selected from the previous step. When a new node is created, it will check the existing selection in the scene and if it makes sense, it will attempt to automatically connect to the selected node(s).
- The default value of the Float Input node is 1.0, which does not change anything because any value times 1 is still the same value. So we have to change the value of the Float Input down to something like 0.03
- With the Float Input node still selected, change the "Float" spinner in the Command Panel to 0.03.
- RESULT: Now we can start seeing the position values "flowing" away from the origin, but the majority is still rather blue because the Z axis is the only component of the position vector that is totally positive (since the pivot point of the Teapot is at its base and not in the center).
- From the opposite side, it looks like this:
Shifting The Position Channel Value
- We could shift the Z component of the Position Channel down to introduce both positive and negative values to the Blue component.
- To do this, we have to select the Position Channel input node and hit the + key on the Numeric Pad to insert an Add Operator between the Input and the Multiply Operator:
- RESULT: Again, we have one unconnected (red) socket in the Add operator and an ERROR report at the bottom. Also note that the particles disappear in the viewport because there is an error on the stack and they cannot display correctly until the error is fixed or the modifier disabled.
- Then we hit the V key which creates a Vector Input node that can be used to provide any value with three components, including RGB colors, XYZ positions etc. The default value of the Vector Input node is [1,1,1], but we will need to change that.
- In the Command Panel, we enter 0,0,-20 which results in the following colors:
Disabling an Operator (Pass-Through)
- A concept inspired from other node-based environments like Eyeon Fusion, the Pass-Through allows an Operator to be disabled and pass the data from its first input socket to the output socket without processing it.
- For example, if we wanted to disable temporarily the addition and get the previous result without touching the Vector input's value, we could simply turn off the Add Operator and pass through the Position Data directly to the Multiply Operator. The Vector Input will be totally ignored because it is connected to the second socket of the disabled operator.
- To disable the Add Operator, we simply select it and hit Ctrl+P.
- RESULT: The node's text turns bright gray. If we would deselect it, it will appear much darker than it was when it was active (compare to the Multiply Operator's color):
- The particles look just like before we added the Add Operator:
Swapping Inputs and Vector As Color
- Right now, the Position Channel is passing through the disabled Add Operator because it happened to be connected to the first socket.
- What if we wanted the Vector Input to pass through instead? Obviously we could rewire the sockets manually, but there is a faster way - simply swapping the intputs using the Ctrl+W keyboard shortcut (also inspired by Eyeon Fusion).
- Select the disabled Add Operator and hit Ctrl+W to swap the input sockets.
- RESULT: The Vector will now become the first input node and will be passed through. Since the value is still 0,0,-20, the particles will turn completely black.
- We can change the Vector node's value to 0,0,100 which will then get multiplied by 0.03 and result in a blue particle color.
- Alternatively, we could set the value of the Vector node to 0,0,1 and Disable the Multiply Operator by selecting it and pressing Ctrl+P.
- At this point, the color value specified in the Vector Input will be reflected directly by the particles because its value is passed through directly to the Output node without any changes. You can use the "As Color" color swatch to pick the exact color you want.
Exposing Controls To The KCM UI
- Let's flip the sockets of the Add Operator again and enable the Multiply Operator - we select the Add Operator node by clicking it, then we press Ctrl+W to swap the input sockets, then we select the Multiply Operator and press Ctrl+P to enable it and stop passing through it.
- Let's assume that you want to use this color scheme in production, but you want to vary the multiplication factor, possibly even animate it over time to create some fancy color effect. It would be much easier to work with the KCM if the Float Input node providing the Multiplication factor were the only control to deal with (and some real production flows can become rather complex).
- MagmaFlow provides the ability to expose Float, Integer and Vector Input Node's values to the User Interface of the KCM as simple spinners that can be used to change the values in the flow without opening the MagmaFlow editor.
- This is also very useful when you are creating a rig to be used/modified by somebody else without MagmaFlow/Krakatoa knowledge.
- To expose the Float Input value to the KCM's UI, simply right-click the node (without even selecting it first) and pick Expose Control from the right-click context menu.
- RESULT: The letter E will appear in front of the node's name (denoting it is exposed), and a new spinner marked "4: Float:" will appear in the Exposed Parameters rollout of the KCM modifier.
- At this point, you could change or animate the spinner in the KCM's rollout to get the colors on the teapot brighter or darker.
Saving the Flow To Disk
- Let's now save this flow we just created to disk for later use.
- In the MagmaFlow Editor, go to the File menu and select Save Flow As.... Alternatively, with the Editor in focus, hit Ctrl+S (if the editor is not in focus, you might accidentally save your MAX file, so it is safer to use the menu):
- The Save Dialog will open at the default location for saving MagmaFlows which is normally located in
C:\Documents and Settings\YourUserName\Local Settings\Application Data\Prime Focus\Krakatoa\MagmaFlows\
- You can create sub-directories in this location (one level deep) to better organize your flows.
- For example, create a new folder called "Tutorials" and enter the name "PositionToColor" in the File name field:
- Press the Save button to save the flow to disk.
Note that if you animated the Float Input value, the animation itself will NOT be saved with the flow, only the basic nodes and connections between them will be stored. You will have to save the MAX scene containing the flow in a KCM to preserve all animation and other external data not discussed here.
Loading Flow From Disk - The Quick Way

- Let's see how this saved flow could be loaded again. Obviously, the File menu in the MagmaFlow Editor has an Open Flow... option, but that is the slow way to do it.
- Let's delete the KCM modifier from the PRT Volume object. This way we are starting from scratch!
- Now add a fresh new KCM modifier to the PRT Volume again. By default, it will once again contain a Color To Color flow which does nothing.
- Now in the UI of the KCM, take a look at the two drop-down lists.
- The top list shows by default [MagmaFlows Root Folder], but if you click it, you will see your new Tutorials folder listed! Select it and the second list which starts with [Custom Flow] by default will show your new flow!
- Select the name "PositionToColor" from the second list and the flow will be loaded and the particles in the viewport will once again be colored like before.
- If you would open the MagmaFlow Editor, everything should be like it was when you save it, except eventual keyframe animations of the values that would not save with the flow since they are part of the MAX scene itself.
Modifying The Flow Once Again - AbsoluteValue
- In the previous examples, we had the Position of the particles converted to Color, but a large portion of the particles had the color components negative and thus clamped at zero wherever the X, Y and/or Z was negative.
- We could easily modify our existing flow to remove the negative sign and assume positive numbers on both sides of the origin.
- We can enable the Add operator in the flow we just reloaded and make sure the Vector Input's value is set to something like 0,0,-25.
- We select the Multiply Operator and hit the A key which creates an AbsoluteValue Operator. This operator works on Float, Integer and Vector inputs and in the case of the Vector input calculates the absolute value of every component.
- RESULT: The Colors are now symmetrical on both sides of the Teapot:
- Let's save this version of the flow under a new name in the same folder - go to File>Save Flow As..., go to the "Tutorials" sub-folder and save as "PositionAsColorAbs"
Loading Flows and the Custom Flow Auto-Backup
- Now we have two custom flows saved on disk. Let's see how you can browse flows without losing your current work.
- Currently, we have the Absolute version of the flow loaded in the editor.
- Let's even modify it a bit, for example let's expose the Vector value to the KCM's UI - right-click the Vector Input and select Expose Control - a new group of 3 spinners with title 6: Vector will be created in the Modify Panel of 3ds Max.
- At this point the Editor contains a CUSTOM version of the flow that is not saved to disk yet.
- What would happen if we would go and load the old "PositionToColor" flow from the UI's drop-down lists?
- Select the folder "Tutorials" from the first list.
- Select the flow "PositionToColor" from the second list.
- RESULT: The Editor's content will change to the old saved flow and the Teapot will turn into the old colors without the AbsoluteValue operation.
- Remember that the second list in the KCM's UI contains an entry [Custom Flow] which is the default selection?
- Whenever you work on a flow in the Editor and make changes, MagmaFlow will mark your current work as "Custom" flow.
- If you would load a flow via the KCM's UI, your current work will be saved to a Temp folder in the MagmaFlows root folder.
- If you then decide that you want to go back to your previous work, you can simply select the [Custom Flow] entry from the list and your previous flow will be restored as you left it.
- If you modify (create at least one Undo record) in the newly loaded flow and then try to load yet another flow, the previous modified one will become the "custom" one and replace the backup copy on disk.
- If you do not click in the Editor while selecting multiple saved flows, each one will be loaded but the old custom flow will be kept around until you finish your "trip through the folders". Then you can select [Custom] again and you will be back to your original work.
- Let's try this out.
- Select the "PositionToColorAbs" from the list - the flow will be changed again, and the particles will reflect the change.
- Notice that the saved version we just loaded does not have the Vector exposed to the KCM's UI - as you load flows from disk, the KCM will update with the saved exposures.
- Now select [Custom Flow] from the list again - the old unsaved Absolute Position To Color flow with the exposed Vector Input should appear back in the editor because it was backed up automatically when we started loading saved flows.
- Now let's see how the loaded flow can become the current custom flow:
- Load the "PositionToColor" flow again.
- Select the Add Operator and hit Ctrl+P to disable it.
- Load the "PositionToColorAbs" flow again.
- Now select [Custom Flow] from the list - since we modified the "PositionToColor" (disabled an Operator) before loading the "PositionToColorAbs", our backup flow now contains the last thing we worked on, the "PositionToColor" with the disabled Add Operator. The old backup flow that had the Vector exposed is now lost.