From BlenderWiki

Jump to: navigation, search
Blender 2.43+

[edit] Creating Alternating Bricks or Cobblestones with Procedural Textures

File:Tutorials-Textures-Bricks and Cobbles.jpg
Bricks and Cobblestones example by Steve Schonberger.

Procedural textures are very flexible, and used in combination can produce effects that may not be immediately obvious. In this example, we will see how to use combinations of Wood textures to generating mortar lines in staggered bricks. As a bonus, similar procedures can generate staggered cobblestones.

Because of the nature of Blender's Wood feature, rotation and scaling are critical to aligning the different procedural texture layers properly.

[edit] An Example Construction

A four-angle view of example construction.

For most of this tutorial, we will use the model above. It is a 4×2×4 block centered on the origin, with three blocks added: an 8×2×4 block along the x axis, a 4×2×4 block along the y axis, and a 4×2×2 block along the z axis. This tutorial's screen captures are lit with these two Lamps:

  • Sun, Energy 1.0, RGB (1.0, 0.95, 0.9), (RotX, RotY, RotZ) = (50, 0, -30)
  • Hemi, Energy 0.5, RGB (0.8, 0.9, 1.0), (RotX, RotY, RotZ) = (0, 0, 0)

[edit] Brick Color and Texture

Before getting into the details of the mortar lines, we will start with the bricks themselves. (Impatient readers may wish to skip ahead to the next section, Drawing the Mortar.) Bricks vary widely in color, but are traditionally some shade of red. Here we will use a dark red with a slight bluish cast to it, and just a hint of specular reflectivity.

Brick Material settings.

The following three texture settings will affect both the brick and the mortar. They must be placed after the mortar layers, because the mortar layers use Lighten and Darken settings in the Map To box, rather than the usual Mix.

[edit] Clouds 1: Rough Surface

The first texture gives the bricks a general rough surface. Create a Clouds texture, reduce NoiseSize to 0.025, and boost NoiseDepth to 6.

Clouds 1 Texture settings.

On the Colors tab, add a Colorband. These color settings work nicely, to give the bricks just a hint of low-level texture and color variation:

  • Cur: 0, Pos 0.3, A 0, RGB (0, 0, 0).
  • Cur: 1, Pos 1, A 1, RGB (0.3, 0.5, 0.4).
Clouds 1 Colors settings.

On the Map To tab, select Nor, and reduce Col to 0.8:

Clouds 1 Map To settings.

On the Map Input tab, change Orco to Glob. This setting is also used for Clouds 2 and Voronoi, below.

This is a cheat, since it doesn't scale with the mortar, but if the texture of the bricks doesn't look right, we can adjust the sizeX, sizeY, and sizeZ settings also.

Map Input settings for Clouds 1, Clouds 2, and Voronoi.

[edit] Clouds 2: Specks and Lumps

The second texture gives the bricks specks and lumps on a larger scale than the general roughness of the first texture. Create a Clouds texture, change Soft noise to Hard noise, reduce NoiseSize to 0.05, boost NoiseDepth to 3, and reduce Nabla to 0.01.

Clouds 2 Texture settings.

On the Colors tab, add a Colorband. These color settings work nicely, to give the bricks brighter, larger-scale texture and color variation:

  • Cur: 0, Pos 0.4, A 0, RGB (0, 0, 0).
  • Cur: 1, Pos 0.8, A 1, RGB (0.5, 0.7, 0.6).
Clouds 2 Colors settings.

On the Map To tab, select Nor, and reduce Col to 0.7:

Clouds 2 Map To settings.

On the Map Input tab, change Orco to Glob. This setting is also used for Clouds 1, above, and Voronoi, below.

[edit] Voronoi: Surface Bubbles

The third texture gives the bricks some small surface bubbles. Create a Voronoi texture, and reduce Size to 0.1.

Voronoi Texture settings.

On the Colors tab, add a Colorband. These color settings work nicely, to give the bricks surface bubbles of reasonable size:

  • Cur: 0, Pos 0.15, A 0, RGB (0, 0, 0).
  • Cur: 1, Pos 0.3, A 1, RGB (1, 1, 1).
Voronoi Colors settings.

On the Map To tab, deselect Col, select Nor, and reduce Nor to 0.3:

Voronoi Map To settings.

On the Map Input tab, change Orco to Glob. This setting is also used for Clouds 1 and Clouds 2, above.

[edit] Tuning the Brick Texture

Bricks vary in color and texture. Some are lighter, closer to terra cotta color. Lighter colors will work as long as all three color components (R, G, B) are darker than the corresponding color components in the mortar color. (To make use a brick color lighter than the mortar color, see the section Modifying the Results, below.)

Some bricks have fairly glossy surfaces. Such bricks typically have smoother surfaces, and most surface texture is aligned along the vertical axis, or less often along the horizontal axes. To reproduce such bricks, increase the specular reflectivity of the base material, reduce the strength of the Clouds 1 roughness, and reduce the size of the Voronoi bubbles. To align surface texture along the vertical axis or horizontal axes, change the sizeZ scaling of the Clouds 2 specks and lumps.

[edit] Drawing the Mortar

As with bricks, mortar lines vary in appearance. Here we will use a traditional light gray color, and fairly uniform texture. A slightly concave surface would be desirable if the surface were to be viewed closely, but that is not necessary from a distance.

The appearance of the mortar is controlled by the Texture and Colors settings for the Wood yz, Wood xz, and Wood H textures, detailed below. Since their Texture Types, Wood are not normal to the X, Y, or Z axes, they also need geometric transformations to adjust their alignment.

The mortar lines are actually positioned along planes between the bricks. As viewed from the front of a wall, there are edge-on vertical planes of mortar, interrupted by alternating bricks, and horizontal planes of mortar. If there are multiple courses of bricks, there are also vertical planes of mortar parallel to the front of the wall, hidden behind the front course of bricks. The edge-on vertical planes of mortar are represented by the Wood yz texture, the optional planes of mortar between courses of bricks are represented by the Wood xz texture, and the horizontal planes of mortar are represented by the Wood H texture.

An additional texture is used to remove half of the mortar from the edge-on vertical planes, to produce the staggered brick effect. Real bricks are not made by erasing mortar lines, but that is a convenient way to render them. The Wood Erase texture does this; it is detailed in the next section.

[edit] Geometry

Wood is the Texture Type that renders periodic textures, but its default orientation is normal to an (x, y, z) vector of (1, 1, 1).

To transform the Wood mortar textures so that they are normal to all three axes requires some 45° rotations. Those rotations change the scale of the mortar lines relative to the three axes, so they must be scaled back to proportions that are convenient for removing alternate mortar columns in the Removing Alternating Mortar section.

The order of the the mortar textures is significant. The Wood yz texture must be first, followed by an open space (or two) for the Wood Erase texture. The Wood xz and Wood H textures may be in either order, but both must be after the Wood Erase texture so they are not affected by it.

Three Empty objects are used to scale and rotate the mortar textures. They share several Transform Properties, differing only in their rotational properties. Their (LocX, LocY, and LocZ) are all 0, their ScaleX is 10, and their ScaleY and ScaleZ is 14.1421356 (10×√2). They also share Empty Master as a Par (parent object), as detailed in the Scaling and Positioning the Mortar section.

All that really matters about the scales is that ScaleZ and ScaleY are equal, and that they are √2 times larger than ScaleX. Because √2 is a number with an infinite number of digits, it's useful to use larger numbers to reduce rounding error, which is particularly important when texturing large objects. That is the reason for the (10, 10×√2, 10×√2) scale instead of just (1, √2, √2).

Why the 1:√2:√2 ratio? It comes from the hypotenuse of a right triangle with two equal sides; the hypotenuse is √2 times the length of the other two sides. That is a convenient ratio when alternating mortar columns are removed later.

[edit] Common Settings for the Three Wood Textures

These settings apply to all three of the Wood textures detailed below:

On the Texture tab for each of the three Wood textures (Wood yz, Wood xz, and Wood H), select BandNoise, Saw, and Soft noise, reduce NoiseSize to 0.01, and reduce Turbulence to 0.3.

Texture settings for each of the three Wood textures.

On the Colors tab for each of the three Wood textures, add a Colorband. These color settings work nicely, to produce mortar lines of reasonable width and color:

  • Cur: 0, Pos 0.4, A 0, RGB (0.4, 0.4, 0.4).
  • Cur: 1, Pos 0.47, A 1, RGB (0.4, 0.4, 0.4).
  • Cur: 2, Pos 0.53, A 1, RGB (0.4, 0.4, 0.4).
  • Cur: 3, Pos 0.6, A 0, RGB (0.4, 0.4, 0.4).
Colors settings for each of the three Wood textures.

On the Map To tab for each of the three Wood textures, select Nor, and change Mix to Lighten

Map To settings for each of the three Wood textures.

[edit] Wood yz: Mortar Columns

The Wood yz texture uses the common settings described above. As shown in the Preview, its Wood texture is positioned diagonally. The Empty object Empty yz is used to transform it so that the gray planes of mortar are parallel to the y-z plane. The two 45° rotations bring the mortar planes vertical, parallel to the y-z plane. The scaling is explained in the Geometry section, above. (The scales don't need to be locked, but it is probably a good idea.) The Par setting will be explained below; ignore it for now.

In the Transform Properties box for Empty yz:

  • Set RotX and RotY to 45, and leave RotZ at 0.
  • Set ScaleX to 10, and ScaleY and ScaleZ to 14.1421356 (10×√2).
Transform Properties settings for the Empty yz Empty frame.

The problem (for the moment) with these mortar lines is that they are continuous, which would result in small bricks without alternating mortar lines. The effect of longer bricks and alternating mortar lines is produced by diagonally wiping out half of the mortar lines in this texture layer, as detailed below.

Empty yz RotX 45, RotY 45, RotZ 0

[edit] Wood xz: Mortar Planes between Layers (Optional)

(Explanation that this is only necessary for multi-layer brick walls)

As with the Wood yz texture above, the Wood xz texture needs to be transformed from its initial diagonal orientation, by the Empty object Empty xz. The two 45° rotations are the same used by Wood yz; they bring the mortar planes vertical, parallel to the y-z plane. Since this layer needs to be parallel to the x-z plane, an additional 90° rotation is necessary to finish the job.

In the Transform Properties box for Empty yz:

  • Set RotX and RotY to 45, and set RotZ at 90.
  • Set ScaleX to 10, and ScaleY and ScaleZ to 14.1421356 (10×√2).
Transform Properties settings for the Empty xz Empty frame.

Empty xz RotX 45, RotY 45, RotZ 90

[edit] Wood H: Horizontal Mortar Planes

As with the Wood yz texture above, the Wood H texture needs to be transformed from its initial diagonal orientation, by the Empty object Empty xy. Instead of transforming the texture to parallel with the y-z plane, however, it is transformed to the horizontal (or x-z) plane. That requires a +45° RotX rotation and a −45° RotY rotation.

In the Transform Properties box for Empty xy:

  • Set RotX to 45, RotY to −45, and leave RotZ at 0.
  • Set ScaleX to 10, and ScaleY and ScaleZ to 14.1421356 (10×√2).
Transform Properties settings for the Empty xy Empty frame.

Empty xy RotX 45, RotY -45, RotZ 0

Note: "Wood H" could have been named "Wood xy" because the x-y plane is horizontal. But because both Wood yz and Wood xz are vertical planes, the name "Wood V" would be ambiguous.

[edit] Removing Alternating Mortar Columns

(Explanation of how the mortar lines in the front plane are interrupted for alternating courses of brick)

Combining the dark red brick color (Figure 1, top-left), and the common Wood texture (Figure 1, bottom-left) with a Map to mode of Lighten (Figure 1, top-right), produces a pattern of dark red brick color with gray mortar lines (Figure 1, bottom-right).

Figure 1. How the Wood Eraser planes interrupt mortar lines, step one: lighten the brick color with mortar lines.
(The bottom-right "screen shot" is simulated in an image editor: darken the brick color with the bottom-left image.)

Rotating the dark red brick color with gray mortar lines (Figure 1, bottom-right) by 45° and scaling it, then combining it with the Wood Eraser plane (Figure 2, center) with a Map to mode of Darken (Figure 2, left), produces a pattern of dark red brick color with interrupted gray mortar lines.

Figure 2. How the Wood Eraser planes interrupt mortar lines, step two: darken the bricks and mortar lines with the Wood Eraser layer.
(The right "screen shot" is simulated in an image editor: rotate Figure 1, bottom-right 45°, scale×0.7071 [sin(45°)], then darken with the middle image.)

(Goes into one or both open spaces after Wood yz)

Wood Erase: Wood Colors A 1 (all); RGB 0.4, 0.1, 0.15 (same as brick material color) Pos 0 and 0.51; RGB 1, 1, 1 Pos 0.01 and 0.49; BandNoise, Saw, Soft noise, NoiseSize 0.01, Turbulence 0.3; Map Input Object Empty Erase; Map To Col, Darken, "Do not select Map To Nor, except to see why it doesn't work, which is somewhat interesting."

(If necessary, add a second Wood Erase with Map Input sizeZ -1 (everything else the same) to avoid asymmetry in the joint between vertical and horizontal mortar lines)

Empty Erase LocX, LocY, LocZ all 0; ScaleX and ScaleY 20, ScaleZ 14.1421356; RotX and RotY 0, RotZ -45

In the Transform Properties box for Empty Eraser:

  • Set RotZ to −45, and leave RotX and RotY at 0.
  • Set ScaleX to 20, and ScaleY and ScaleZ to 14.1421356 (10×√2).
Transform Properties settings for the Empty Eraser Empty frame.

"Note that the ScaleX and ScaleY are exactly double and the ScaleZ is exactly the same as the corresponding scales of the Empty objects above. If they're not, this texturing layer won't work properly."

[edit] Holes in the Top

"This requires individually modeling holes in the bricks, so it's beyond the scope of this article. Normally the tops of brick walls aren't visible anyway, since builders don't want rain to fall in the holes."

[edit] Scaling and Positioning the Mortar

(Explanation of the master Empty that controls scaling and positioning)

"Create an Empty (I name mine Empty Master) and make it the parent of all the other Empty objects. Set the scales as appropriate to the size and proportions of the bricks; I used 0.2 to scale down the large proportions of the other Empty objects. To change the aspect ratio of the bricks from 2:1:1, the master Empty may have a different scale along each axis.

"Set LocX, LocY, LocZ all to 0. (Those figures don't work well for this demonstration shape.) That point is the midpoint between mortar lines on each axis. Adjust the location of the mortar lines by moving the Empty to an appropriate point. In particular, make sure the mortar lines don't end up in the same plane as a large surface, or else the mortar will hide the bricks."

In the Transform Properties box for Empty Master:

  • Set LocX to −2, and set LocY to −2, and set LocZ at 2.
  • Set ScaleX, ScaleY, and ScaleZ to 0.2.
Transform Properties settings for the Empty Master Empty frame.


[edit] Modifying the Results

(Wrap-up with comments on specific limitations)

"To use mortar that's darker than the bricks, reverse the Lighten and Darken settings on the mortar line layers and the Mortar Erase layer, and replace the white in the Mortar Erase's Colorband with black. In that case, none of the R, G, B values in the mortar may exceed the corresponding values in the bricks. In other words, pure red (1, 0, 0) bricks and pure green (0, 1, 0) mortar won't work, because the Wood Erase texture layer will either darken the green to black or lighten it to white. (It may be possible to make it work, but I haven't looked for it.)

"One can produce alternating mortar lines in both the yz and xz planes, by rotating the Empty Erase 45 degrees around the z axis. This will look good on strictly rectangular buildings, but wrong on exposed surfaces that aren't parallel to the yz, xz, or xy planes.

"Try switching each of the texturing layers on and off. Turning off Wood xz may save rendering time if only one face of a brick surface is visible. Turning off Wood Erase gets rid of the alternating mortar lines."

[edit] An Example Modification: Cobblestones

(Rotate Empty Master, change colors, reverse Lighten and Darken)