4

enter image description hereHow do I make it repeat itself along the X-axis?

ilyak
  • 145
  • 1
  • 13

2 Answers2

6

This is a little more complex than the linked question due to the spherical gradient texture needing a range of [-1,1] to generate a full circle.

The modulo(1) function will generate a repeating pattern by mapping positive values to a new value in [0,1] and negative values to a value in [-1,0]. This means that half the circle will be repeated in either direction from 0, not what we want.

Instead we can generate two versions of our repeating pattern that each work for just one side of the zero point, and then combine them by masking out values we don't want and using a maximum: enter image description here

  1. Modulo(x,2) - 1 generates a repeating [-1,1] range for x > 0 and [-3,-1] otherwise
  2. Modulo(x,2) + 1 generates a repeating [-1,1] range for x < 0 and [1,3] otherwise. This [1,3] range will present problems when combining each side with maximum so we need to set it to something less than or equal to 0
  3. By exploiting the fact that the spherical gradient is symmetrical around x=0, we can invert the part from (2) to avoid the issues with maximum.
Sazerac
  • 4,619
  • 4
  • 20
  • 33
6

Just out of interest.. (this is no better than @Sazerac's answer) .. this set of nodes has the same effect as Sazerac's cluster between the Mapping and Gradient nodes, this time placing the full gradient in the ranges ...[0,2],[2,4]... of whichever space you are using.

enter image description here

The graphs in the illustration below show the sequential effects on the mapping of X by the numbered nodes.The squares are all 8 units on the side.

enter image description here

Thanks to @Rich Sedman for the tip on how to display graphs of f(x).

Robin Betts
  • 76,260
  • 8
  • 77
  • 190