# Bevel a Procedural Texture?

Is it possible to bevel the outline of a procedural texture?

This would be the desired effect (result prepared with an image editor):

For example, we have the default Brick Texture, and its Mortar Size can be thickened, but there is no built-in parameter to taper off the edge with a bevel to give it a more rounded look.

Bricks with the default settings (left) and thickened mortar (right)

The best idea I can think of is to stack Brick Texture nodes of different Mortar Sizes to create a stepped gradient. That however has resolution limitations, plus using that many nodes may negatively impact render time.

So I am wondering if anyone with a bit more vector know-how than myself knows of a way to generate a vector curve that transitions between two mortar sizes to achieve the result more elegantly. Any ideas?

Here is a concept image - the blue curves representing the vector transition:

• This is not possible by default. it will take some complex work arounds if possible at all. Nov 5, 2015 at 2:27
• I have pondered how to do this exact type of thing in my head for a long time. As far as I can figure out it is not possible. Cycles has no concept of an entire texture, just the color of the pixel of the texture at the particular point given by the mapping coordinates of the point where the current ray has stuck the object. (If that made any sense at all.) Nov 5, 2015 at 2:28
• @PGmath Nice to know I'm not the only one pondering. I just added a concept image to the question, but I don't know that it helps or changes anything. It seems like there ought to be a way to push vector data through the brick texture on its Z axis and bend it toward a target (the smaller brick faces). But I get what you're saying as well, and I'm not surprised that people are saying it's probably not possible. I had to ask the question though to ease my curiosity. Nov 6, 2015 at 15:01
• I think OSL would be ideal for this ? Nov 6, 2015 at 15:04

Based on a modified version of this OSL bricks shader, I added a smoothness parameter that generates a smoother transition from the mortar color to the brick color (Currently will work in the desired manner only with values ranging from 1-10. Will probably improve algorithm tomorrow).

# include "stdosl.h"

float BMWIDTH = 5,
float BMHEIGHT = 5,
float MORTARTHICKNESS = 0.1,
point Vector = P,
int   smoothness = 1,
color Cbrick = color (0.5,0.15,0.14),
color Cmortar = color(0.5, 0.5, 0.5),
output color Col_Out = color(0.7)
)

{
color Ct;
point Nf;
float ss;
float tt;
float th;
float sbrick;
float tbrick;
float w;
float h;

float x = Vector[0];
float y = Vector[1];

float smoothnessFac = 0.1;
for ( int i = 0; i < smoothness; i++ ) {
float MWF = MORTARTHICKNESS * ( 1 + i * smoothnessFac ) * 0.5 / BMWIDTH;
float MHF = MORTARTHICKNESS * ( 1 + i * smoothnessFac ) * 0.5 / BMHEIGHT;

ss = x / BMWIDTH;
tt = y / BMHEIGHT;

if (mod(tt * 0.5, 1) > 0.5)
{
ss += 0.5;
}

sbrick = floor(ss);
tbrick = floor(tt);

ss -= sbrick;
tt -= tbrick;

w = step(MWF,ss)  - step(1-MWF,ss);
h = step(MHF, tt) - step(1-MHF, tt);

if ( i == 0 ) {
Ct = mix(Cmortar, Cbrick, w*h);
} else {
color current = mix(Cmortar, Cbrick, w*h);
Ct = mix( Ct, current, 1 - i * smoothnessFac );
}
}

Col_Out = Ct;
}


• This is awesome! Nicely done. Any idea why the scale is so different from the Cycles Brick Texture? I made a cube and plugged the same vector data into both textures but the OSL texture is huge and I can't seem to get it to line up with the Cycles one. (I tried to layer them with a MixRGB node on Multiply so that the brick color variation of the original Cycles texture gets included) Nov 8, 2015 at 2:04

There's something of a workaround, but it stops you from being able to tweak it. Turn all the settings black and white and render it with a shadeless node (hook it up to the emission color) on a plan large enough for your texturing needs. Render and save the image. Blur the edges in an outside image editor, making sure you keep the blurring within the boundaries of the white bricks. Alternately, for a sharper bevel, apply 50% gray to the inner edges of the bricks. Even a gradient out to the black. Then reapply the texture as an image texture displacement.

The gray is what gives it that level difference.

I hope that helps.

• I think the OP is looking for a procedural method, his example was made using this method. Nov 6, 2015 at 20:45