-
2$\begingroup$ Possible duplicate of Repeat a generated texture in Cycles? $\endgroup$– Duarte Farrajota Ramos ♦Apr 23, 2019 at 23:14
-
$\begingroup$ Yeah, I tried their methods and none of them worked out for me. $\endgroup$– ilyakApr 23, 2019 at 23:25
-
1$\begingroup$ Then how about giving us something to work with? More than one sentence? Adding images? You can edit your question to make it better. $\endgroup$– metaphor_setApr 23, 2019 at 23:32
-
$\begingroup$ done that, thought it was clear enough $\endgroup$– ilyakApr 23, 2019 at 23:39
2 Answers
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:
Modulo(x,2) - 1
generates a repeating [-1,1] range for x > 0 and [-3,-1] otherwiseModulo(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- 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.
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.
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.
Thanks to @Rich Sedman for the tip on how to display graphs of f(x).