Where to use Modulo or Wrap shader nodes in Blender

When designing procedural materials, we typically use the Modulo node when we need to create a cyclical pattern over a specific area of ​​the surface. However, this node has a feature: it correctly processes only positive values ​​and clips all values ​​below zero.

Let’s create a simple scene to demonstrate the effect.

First, add a default plane (shift + a – Mesh – Plane) to the scene, located in the X-Y coordinates, and assign it a base material.

Add a Texture Coordinates node (shift + a – Input – Texture Coordinates) to this material node tree. Connect the “Object” output from the Texture Coordinates node to the “Base Color” input of the Principled BSDF node. This way, we color-code the plane’s coordinates. The coordinate system’s origin (0.0, 0.0) in this case will coincide with the plane’s origin.

The origin in our case is located in the plane’s center, so we can immediately see the color distribution along the positive and negative axes. Red is the X-coordinate, green is the Y-coordinate.

Let’s say we now want to create a repeating pattern from this color distribution.

In most cases, the Modulo node is used for procedural looping. Add it (shift + a – Utilities – Vector Math – switch to “Modulo” mode) after the Texture Coordinates node. Use the object coordinates as the first input, and set the second input to one (1.0, 1.0, 1.0). This creates a repeating coordinate pattern on a 0.0 – 1.0 interval.

Add a Scale node (shift + a – Utilities – Vector Math – switch to “Scale” mode) before the Modulo node. Set the scaling value to, for example, 3. This reduces the scale by a factor of 3.

Now we can see our pattern—a coordinate loop along the current axis between 0.0 and 1.0, scaled down by a factor of 3.

And here we clearly see that negative values ​​on both axes are discarded during pattern generation.

If we want to create the same repeating pattern for negative coordinate values, we need to add additional nodes to move or mirror the values ​​along the X and Y axes.

However, there’s a simpler way.

Add a Wrap node to the tree (shift + a – Utilities – Vector Math – switch to “Wrap” mode) and switch the branch from the Modulo node to it. Set the value in the node’s second input to one (1.0, 1.0, 1.0).

Now, without any additional nodes, we immediately obtain our pattern, replicated for both positive and negative coordinate values.

This happens because the Wrap algorithm, unlike the Modulo algorithm, takes the absolute value of the difference between the looped values, not the signed value.

Therefore, by using the Wrap node instead of the Modulo node, we can simplify the generation of cyclic patterns if they are required for both positive and negative object coordinate values.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments