Is there a way to repeat a gradient texture? (2.8 beta)

Have been trying for a while to work out how to get a gradient texture to repeat so when i change the texture location in the mapping node the colours will move and the ColourRamp will repeat. All i can think of doing is making an image file of the gradient and then using that as the texture but surely there is a way with the procedural texture?

Here’s a very basic set up, also tried with texture co-ordinate node but to no avail;

Thanks in advance!

Coordinate -> Mapping -> SeparateXYZ -> 3xMath Modulo by 1 -> CombineXYZ -> Gradient -> Colorramp.

1 Like

Sweet I’ll try that now, is there any chance you could give a little explanation as to why these processes create the intended result? Cheers!

Modulo by 1 makes stuff repeat.
Modulo is what is left over if you divide something.
For example
10 mod 5 is 0
because 5 fits into 10 exactly twice with nothing remaining.

11 mod 5 is 1
because 5 fits into 11 twice with 1 remaining. This remaining 1 is what modulo means.

Modulo 1 of 0.1 is 0.1
because 1 fits into 0.1 zero times with 0.1 remaining
Modulo 1 of 0.2 is 0.2
Modulo 1 of 0.3 is 0.3
and so on
Modulo 1 of 1.1 is also 0.1
because 1 fits into 1.1 one time with 0.1 remaining.
Modulo 1 of 1.2 is 0.2
Modulo 1 of 1.3 is 0.3
and so on

so you see, no matter what the number before the period is the modulo will allways be the value behind the period giving you a repeating pattern.

2 Likes

Thanks man, super helpful explanation about something I didn’t even know existed!! Is there any other cool/interesting uses for Modulo apart from looping stuff? Can’t believe I hadn’t heard of it before haha

Well, multiplication and modulo by two different “large” (not that large actually) primes can apparently be used to create some pseudo random number. See this thread, but don’t look at the first image:

oooh interesting I’ll check it out, thanks man!