# How to create a Life Preserver style texture?

A friend of mine is creating a mint object and asked me about how I would approach creating the Life Preserver/Mint style texture. I've done similar things before with striping using a Wave Texture & a ColorRamp node, looking like this: To go for the life preserver effect I've used a gradient texture instead. This is the setup I have right now: I'd really like to use math to control the number of stripes instead of playing with the Color Ramp values directly. In the horizontal stripe setup I was able to control the amount of stripes by using the location of an empty.

If I do need to use points on the ColorRamp, thats fine, but its pretty awkward to divide 1.0 by the amount of stripes I want. (in my case I want 6, so I need 12 points on the graph).

In essence, I want to have a robust way of creating these rings via the node editor and have the rings have be the same size.

• – cgslav Jun 1 '18 at 10:22

Since you don't want to correctly unwrap each new object we need a procedural shader which uses the angle from the objects origin.  That way you can easily displace and distort without worrying about the UV.

First we need an atan2 node to calculate the circular angle as viewed from top. It is show in the red atan2 box in the node overview. You can also find explanations here. I used the nodes in the first answer. Group them into the atan2 group.

(We'd manage with a simple arctangent node from cycles, but it doesn't hurt to have an atan2 in your library and it's not that complex.)

Use the objects X and Y coordinates as input. Right now the values and in the range [-pi, pi]. Let's normalize them by adding pi and diving by 2*pi. After that, multiply by the number of intersections you wish, and add the modulo and greather than to get separations of 0 and 1. At this point, it would be smart to group the nodes into a rings group. That way, when we make this material a single user to change the colors or the amount of sections all materials will use the same ring group. Lazy as always, I would do this with a similar setup as that of the original question, using the Gradient texture in radial mode, and feed that as vector for a Checker texture instead.

The number of stripes can then be typed directly as scale of the checker node. Think of the value for scale as "how many times does the texture fit within the object". So you can set the precise number of stripes with ease.  Thanks to this post on BlenderArtists I've got a solution. Credit to user Secrop for his setup, though I made one tweak to make it work.

In Secrop's original post, he uses the Y as the input to the multiply node. I simply changed it to be the X. Seems to work exactly as intended.

In order to control the number of turns, you simply set the value node to be one less than the desired amount. • This is not really procedural, since you need a correct unwrap. I've have added a procedural alternative in another answer. – Leander Jun 1 '18 at 9:20