I'm using cycles and have a texture that I want to animate by changing the hue so that it cycles through the rainbow. I know how to make keyframes of nodes, however I'm not sure how to make it seamless when the hue slider operates on a 0-1 scale. Would it just be a matter of changing the animation curves??
1 Answers
You can use a Maths node set to 'Modulo' to convert an input value into a repeating range; the output will vary between 0 and the value set on the second input. For example, with the following nodes :
Varying the 'Value' will produce Hue that varies between 0 and 1, then restarts back at 0. This will produce a continuous repeating range of hues as Value increases from 0 upwards (simply keyframe Value from 0 to, say, 5 to result in 5 repetitions of the range of hues : 0.0->1.0, 0.0->1.0, 0.0->1.0, 0.0->1.0, 0.0->1.0).
As @RobinBetts pointed out, using the Modulo function can cause strange effects then using negative values as the Blender 'Modulo' function (as is the same for many programming languages) flips the output for negative input values. To correct this we can add a couple of additional Maths nodes :
For example, here's the usual output from the Modulo function :
Notice how the output flips in the centre as it crosses zero.
Adding Maths nodes to Add the Value, followed by a second Modulo corrects for this - by effectively shifting all values that are less than zero back to being positive :
- 44,721
- 2
- 105
- 222



(-x) mod yis equivalent to-(x mod y). – Rich Sedman Nov 12 '18 at 07:070 mod xis evaluated as-x, outside the[0.0 , x)range. Nowflooris available, probably better to usex - (y * floor(x/y))– Robin Betts Sep 16 '19 at 22:22