Add-ons and more

Blender procedural hexagon pattern

I needed a texture for a hexagonal pattern that was fully procedural. In the past I wrote one in Open Shading Language but I wanted one that utilized the GPU and worked for Eevee as well. So I implemented a node group that uses basic nodes only. An example is shown below.



The node group is straight forward to use and has options to change the scale and the width of the line. An usage example is shown in this noodle:


Availability


It is available for download from my GitHub repository. To append the node group so that you can use it in your material, simply select File -> Append ..., browse to the .blend file you downloaded and locate the Hex Nodegroup. After that you can use it in the Shader editor with Node -> Group -> Hex

Implementation details


The Hex nodegroup simply overlays three 60° rotated copies of a pattern of dashed stripes


Each dash is the side of a hexagon. The stripes are created with another node group shown below (click to enlarge)


It contains two almost identical frames: one to produce a set of vertical dashes and another one to create a simlar set but offset in the x and y direction. The dashes are generated each time from a wave texture in the x direction that is combined with a greater than node to produce narrow vertical lines. From this we subtract broader horizontal lines generated in the same fashion to create the gaps between the dashes.

12 comments:

  1. Thank you for the file. What version of Blender is this for? I tried loading it with 2.82 but only got diagonal stripes.

    ReplyDelete
    Replies
    1. I don't remember exactly but I think 2.81. But I just downloaded the .blend again and opened it in 2.83.2 and that works fine, both in eevee and cycles ...

      Delete
  2. Thank you for the info I'll give 2.83.2 a try.

    ReplyDelete
  3. Thanks again. It works perfect in 2.83.2!

    ReplyDelete
  4. This is exactly what I was looking for, thank you!

    ReplyDelete
  5. Thank you Michel... also works in 2.90.1

    ReplyDelete
  6. Absolutely perfect, Thank you!
    Great start to the day!
    (3.1.0 Alpha)

    ReplyDelete
  7. Would love to see this done without the hex texture, but with math nodes.

    ReplyDelete
    Replies
    1. That wouldn't be too difficult I guess but I'm pretty sure performance would be hurt quite a lot. It is difficult to beat the efficiency of the built in nodes and this combination of a wave node with a compare node is quite minimal. If you would want to go a math nodes only way the first step you might try is to replace the wave node with a sine . Replacing a map node (for the rotation) is more work, but you only need two rotations of 60 and -60 degrees and you can precalculate the sine and cosine needed for this.
      I am not going to do it myself though, because I don't see the point :-)

      Delete
  8. Nice nice, works perfectly in blender 3.0 thank you !

    ReplyDelete
  9. Thanks so much for this file. I looked for ages, it's simple & perfect... I'm using Blender 4.0 and it works great.Again thank you so much

    ReplyDelete