# How to make a barcode like stripes texture

How could I make this sort of texture using nodes as opposed to assigning materials to faces? Specifically, I would like to be able to scale this in a Node Group.

Shady's Answer works only in this scene and not only in all,So you will have to edit values per scene.

And that's why I prefer using some math Instead.

To get information about our object we will use the texture coordinates node,and use Generated coordinates.

Suppose you want the strips to be vertically,then you should use the Z axis only of the coordinates and that is by using Separate XYZ node.

Now let's do the math,I will first multiply the Z axis by a variable integer which is equal to the number of black or white strips.

Then I will Modulo the result by 1,Which means I repeat the gradient every 1,and since we multiplied the axis by "say 5" then we will repeat 5 times.

Now we have a number of gradients,I will limit them to be either white or black using Greater than node.

Here the node tree: Which will produce the following result: I can group it and expose the variable,and we got our node group: An alternative solution allowing to have regular strips or barcode like strips. Here is the node group setup : Group inputs

• Mapping vector coordinates
• Scale of the strips
• Mode to switch from barcode mode (0) to regular strips (1)

Group output

• a factor between 0 and 1. Or exactly 0 or 1 if the mode input above is 0 or 1

In red is a separate XYZ because we will rely on X value and don't use the Y value : this will give vertical strips. If you want to have horizontal or other, just change the input vector with a mapping, for instance.

The green part is for the barcode (left to right) :

• We recombine the input vector but eliminate the Y value
• A noise texture : the noise is stretched along Y as Y is 0
• The noise texture is scaled by the scale input
• A greater than to obtain 0 if the value is less than 0.5 and 1 if the value is above 0.5 : that gives the strips.

The blue part is for the regular strips (left to right) :

• A scale factor by PI (=3.14159). This previous scale factor is chosen, because we take a sinus to obtain a variation from -1 to 1
• A multiplication by the X vector coordinate
• The sinus
• A greater than to obtain 0 if the value is less than 0 and 1 if the value is above 0 : that gives the strips.

In yellow a mix node which takes into account the mode we want : 0 for barcode like strips and 1 for regular strips. Good question! I prefer to use a Checker Texture and a Vector > Mapping node. Note the small Scale: > X: value. It is what turns the Checker Texture into stripes. Also note that I used Generated Texture Coordinates. This works for most simple objects and eliminates tiresome UV Mapping. This node setup produces the following result when applied to a plane. Note the orientation suggested by the three axes in the bottom lefthand corner of the 3D Viewport. In a different orientation, you may have to toy with the Scale: > Y: or Scale: > Z: values. Also note that as you increase the Checker Texture > Scale: value, you may have to decrease the affected Mapping > Scale: value.

Unfortunately, the Mapping > Scale: values cannot be accessed inside a NodeGroup.

• Additionally you may also use a Gradient texture or a Wave texture, both run through a color ramp node set to Constant interpolation Jul 27, 2016 at 1:36
• Jul 27, 2016 at 2:10