I'm trying to create a procedural rainbow spiral in cycles like this:

reference rainbow spiral

The reference created by rotating the center vertex with proportional editing on, then assigning material slots to multiple colours. I'd like to have something more adaptable, like controlling number of turns and number of iterations of colours.

My attempt at a procedural texture led me to the radial vector which currently has a simple setup like this:


Which then gives something like this:


I have read related questions from Create procedural spiral pattern and How to Twist a Procedural Material? but I'm currently at a loss as to how I could integrate my colour ramp to the nodes given.

Any help would be greatly appreciated, Thank you!

  • $\begingroup$ Related but way more complicated than you require here. blender.stackexchange.com/a/107688/29586 You essentially need to calculate the radial distance from the centre and use that to offset your colorramp via a modulo node. I can’t post an answer right now but if nobody else helps can post a solution on Monday. $\endgroup$ – Rich Sedman Dec 15 '18 at 12:41
  • $\begingroup$ I have read through your solution and tried the blend file provided to try to make sense of it. I also tried the rotation matrix thing but I just couldn't wrap my head around the math involved. It seems you're the guy to ask for this as you've given pretty comprehensive solutions to both the questions I've referenced. Thank you! $\endgroup$ – Rey Leonard Amorato Dec 15 '18 at 13:05
  • 1
    $\begingroup$ Hi Rey. I've added an answer - hopefully this will make sense. $\endgroup$ – Rich Sedman Dec 17 '18 at 0:19

In order to produce a spiral effect, you need to effectively rotate the 'banding' based on the distance from the centre, 'wrapping' around at 1.0 back to 0.0 to continue the pattern.

This can be achieved as follows :


Note the lower branch of nodes - the Dot Product, Power, Multiply nodes. The Dot Product with both inputs set the same will generate the square of the distance from the origin. The Power(0.5) node takes the square root, resulting in the actual distance from the centre. The Multiply node can be adjusted to control the "tightness" of the turns of the spiral.

The Add node then adds this distance into the offset around the spiral - effectively rotating further around the centre the further away from the centre, while the Modulo(1.0) function allows the values to wrap around from 1.0 back to 0.0 to continue the pattern.

Note that I've also added an Add(1.0) and second Modulo(1.0) node - this is to allow for negative rotations to allow the spiral to be twisted in either direction (the normal Modulo function produces odd results when presented with negative values - the additional nodes correct for this - see https://blender.stackexchange.com/a/122489/29586 for more of an explanation for this).

I've also added a Multiply after the radial Texture node. This allows the number of repetitions of the banding to be adjusted. Stick with whole numbers to avoid breaking the pattern - eg, 3.0 will produce 3-times the number of bands.

| improve this answer | |
  • $\begingroup$ This is absolutely brilliant! Looking at the node setup it seems so simple but I never would've figured this out on my own. Thank you so much! Have you got any more examples of using the square root of the dot product? I'm very curious as to where else I can use it. $\endgroup$ – Rey Leonard Amorato Dec 18 '18 at 3:56
  • 1
    $\begingroup$ @ReyLeonardAmorato Glad to help. Using the Dot Product in this way is effectively a shortcut to using Pythagoras theory to calculate a distance (sqrt(x^2+y^2+z^z)). Here are some examples : blender.stackexchange.com/a/70920, blender.stackexchange.com/a/99964 or some more complicated examples : blender.stackexchange.com/a/119604, blender.stackexchange.com/a/92327. Also, an example where sqrt(x^2+y^2) is used instead blender.stackexchange.com/a/98787 $\endgroup$ – Rich Sedman Dec 20 '18 at 7:09
  • $\begingroup$ Thanks for the links! I'm sure these would be handy. $\endgroup$ – Rey Leonard Amorato Dec 21 '18 at 21:55
  • 1
    $\begingroup$ Thank you so much for this example! I am using it to make SPIRAL "The Penguin" Umbrella using SVerchok and Eevee / Cycles Shader nodes! $\endgroup$ – Blender Sushi Guy Sep 12 '19 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.