How do you create a shader that seamlessly wraps a brick pattern around the whole object, so that there are no "Stitches" at any edges/corners?

Take this screenshot for example:

enter image description here

On the left side, the material seamlessly wraps around the edge. On the right side, it doesn't.

Now the question is, how can you make the material seamlessly wrap around all of the geometry's edges? What needs to be done? How would you tackle this in either Godot's VisualShader editor or in Unity's Shader Graph?

My goal is a procedurally generate material that looks like a stone wall. Somewhat similar to this one, just simpler (less chaotic and with less details):

enter image description here

The very first obstacle that showed up (besides having no idea yet how to create the pattern) were the stitched edges, which I thought should be tackled first. Hence the question...

  • 1
    \$\begingroup\$ You've set yourself a difficult challenge here. Adjacent polygons don't know anything about one another inside the GPU pipeline, so they can't scheme together to line-up their brick edges. One way I've solved this in the past was to create a 3D texture containing a brick pattern (each brick was a contiguous span of pixels/voxels of the same colour) and sample that using the worldspace position of the shaded pixel. It requires some mathematical artistry to turn the in-between gradients into convincing looking grout lines though. \$\endgroup\$
    – DMGregory
    Aug 29, 2021 at 14:04
  • \$\begingroup\$ If you don't need full generality (say, something like a series of flat walls that just need the rows of brick to align along their vertical seams), you may be able to get away with a simpler approach using worldspace texturing, something like this. \$\endgroup\$
    – DMGregory
    Aug 29, 2021 at 14:07


You must log in to answer this question.

Browse other questions tagged .