Sample Field
Field objects allow you, among other things, to restrict effects spatially or apply variations to them. With the help of these nodes, you can read the intensity values, colors, and directions of fields at specific positions in space and then use them, for example, for your own effectors or modifiers.
You’ll find an example of how to use them in the explanation of the MoGraph Effector node, where the recoloring and scaling of clones are spatially restricted by a field
Below is another example of how Sample Field can be integrated into your own node setups. There you can see a Nodes Modifier that was dragged from the Asset Browser into the Object Manager so it can be used there as a capsule under an object. After double-clicking the modifier, the Node Editor displays its initially empty contents. In the example shown, the point positions of the geometry are read and shifted 50 units upward. This is essentially the lower part of the node graph. Above it, you can see the Sample Field node, which now allows us to read out any fields and combine their intensities using a Mix node that blends between the original point position and the one shifted along the Y-axis:
1Here you can see the Sample Field node. To easily populate it with field objects in the capsule, drag a connection line from its Field input (see 2) to the light gray area of the node editor, release the mouse button there, and then select Add New input from the context menu.
3A new Field entry appears at the capsule, and the typical Field List element appears in the Attribute Manager, as soon as you select the Nodes Modifier capsule in the Object Manager. To ensure that the Sample Field Node also knows, for example, at which position it should determine the field strength, we connect the currently calculated point position to its Local Position input and assign the Global Object Matrix as its reference system.
4The intensity read from the fields is made available at the Value output of the Sample Field and, in our example, is used to blend between the different point positions. If the field returns an intensity of 0, input 1 is passed through the Mix node, which reflects the original point position. For a field value of 1, the position value modified via the Arithmetic node is used (see 5). In this way, field values can be used to create smooth transitions between different states.
The node graph is now complete and ready to be tested. However, there is one special case to consider: what if the user does not want to use any fields at all? In that case, Sample Field would always return 0 as its Value. This is likely not the desired result. We will therefore add a Boolean switch as a user element to the dialog, which the user can use to specifically choose whether fields should be read or not. In that case, the full effect of the Nodes Modifier would simply be calculated for all points.
1After you opened the Resource Editor (right click into the Node Editor and choosing Edit Resource...), look for the Bool - Checkbox element in the lower left list and drag it from there to the Inputs list right above (see 2). Place it right above the Field list element there.
3When the new checkbox element is selected, you'll find its settings in the middle column of the Resource Editor. There, we select the name Use Field and can then choose under Default Value whether this option should be enabled or disabled by default when a user reopens the capsule.
4The complete dialog of the capsule can always be seen on the right side of the Resource Editor. This is always a good opportunity to double-check the order of the controls before closing the Resource Editor.
1As shown in the figure above, we are now using the new Use Field input to calculate a case distinction within the circuit. To do this, we use a Switch node (see 2) and connect its Index input to the checkbox. The upper input on the Switch is activated when the checkbox outputs 0—that is, when it is unchecked. For this case, we enter the value 1 at the top Switch input (see 3), thereby simulating the full strength of the Nodes Modifier when no fields are to be used. If the checkbox is active, the values of the fields should, of course, be incorporated into the circuit. Therefore, we connect the second Switch input to the Value of the Sample Field node.
The result of the Switch now drives the Mix node again.
The following figure illustrates how our node graph and the integrated evaluation of a Spherical Field object using a custom Remapping curve can work.
