A procedural layered wall in Blender Cycles – Part 1: creating the layers


A section of a wall

This texture was a contest entry in the Facebook page “Blender Procedural Textures”

The Facebook “Blender Procedural Textures” page runs a weekly contest to use procedural textures to match a specific texture, usually from a photograph. This image is similar to my entry for one of the contests. Most of the texture will be familiar to you if you create your own bump pattern and cracks, that are made with common techniques for doing so. The method for creating the layers may not be: it is not the typical approach.

This is a step by step explanation of the approach taken. If you understand what each of the individual nodes do, you will have no trouble following it. The examples were created using Blender 2.79b. Most of the approach should apply to any release with cycles. The displacement will not, but a bump map may be substituted.

Analyzing the texture

This texture can be described as having these parts

  1. The displacement of the underlying wall
  2. Obviously, the paint layers
  3. soft wear, in the forms of speckles and dots
  4. scratches

Normally this could be accomplished using the techniques described in BlenderInsight, Joakim Tornhill’s excellent manual Procedural Wear from A to Z in Blender. The manual can be found in the files section of the Facebook procedural textures page.

A close inspection of the original photograph, (which I do not have permission to post) shows that there is different kinds of wear in each of the segments, possibly because a different pigment was used for each and wore differently.

How to create regions and use them to select between textures

The simplest approach is to create a color ramp and use it to select the colors. Use a gradient texture for the color ramp fac and get something like

Gradient bands with linear color ramp

There are two obvious problems: the bands are vertical instead of horizontal, and they blend. The first is easy to solve: rotate the plane. The second is also easy: switch the color ramp from linear to constant

Rotating the plane is left as an exercise for the reader. The edges are too straight, so add some noise.

Use the multiply to control the strength of the noise texture. Use the color ramp to set the color, number, order and width of bands. This will do for most purposes, but it is very difficult to use it to put a different texture in the blue region than in the green. Is there another way?

Yes.  One way is with math.  It’s easy math, so take a calming breath and follow along. Start by thinking about how to mix two colors, so that one or the other is chosen, but not both. We can do this simply using a greater than node. We can easily split the plane in half this way

This image is produced by this simple node group.

The gradient texture produces a number between 0 and 1. Greater than compares that value to its other value, in this case .5. If the upper value, from the gradient, is greater than the lower value, greater than returns 1, otherwise 0. When the mix input factor is 0, only the top color is used, otherwise the bottom color. You change the width of the region by changing the value being compared to.

Add another region by adding another greater than and mix.

This image is produced by this node group

We can continue to add as many bands as we want.

There is one more feature of the banding to model: the bands slope downward from left to right. One way to do this is through the use of texture coordinates. Replace the gradient texture with a texture coordinates node’s generated coordinates and get

This is not precisely what we want.

This node group will give us exactly the same results as the gradient texture, but for a different reason. Any point on the plane can be described by two numbers, the distance along the bottom, X and the distance along the side, Y. X varies from 0, on the left, to 1, on the right. Y from 0 on the bottom to 1 on the top.

Add the slant by combining X and Y.  We could simply add them, but we only want X to have a small effect, so multiply it by a small number.

This looks good, three bands, slanted in the right direction. Add a little noise and you have what you want.  (Notice that I also rotated the bands).

The texture coordinate provides the position of a point.  The y value is used to select the band edges. As x gets larger going from left to right, it is added to y, giving the slant.

Let’s add a texture that applies only to the blue band, just a simple Voronoi to demonstrate.

This is straightforward. Replace the color in the color mix with the mixed texture. Now let’s add a texture that crosses all the bands.  This is ugly, but it shows the effect.

Add the noise on the borders back in and the result looks like this

and is produced by this

The overlay texture is mixed with the output of the band mixture and provides the color to the diffuse node.

The Failure of Futurism

There is one thing that all widely read futurists have in common: they are wrong, most often spectacularly so. The first is inherent in the limitations of predicting. The second is inherent in the approach futurists seem to universally take.

Perfect prediction requires perfect models, which in turn require complete information. But information is infinite (c.f. irrational numbers) and can only be approximated (c.f. uncertainty principle.)

Accuracy is the measure of a prediction’s success. The closer the prediction matches the observed behavior, the higher the accuracy. The smaller the number of interactions in the behavior being predicted, the less information is necessary to predict the behavior. Applying quantum physics, for example, often entails predicting a single interaction of two particles and can be breathtakingly accurate. Weather, on the other hand, consists of myriad interactions of trillions of objects. Predicting weather can be breathtakingly inaccurate.

Futurists are spectacularly wrong because they consistently predict exponential trends in technology growth when that growth is never exponential. They are wrong because they predict continuous growth when growth will have interruptions. They are wrong because they emphasis the wrong trends. They are wrong because they do not account for side effects.

Study the history of any specific technology. It will start with a discovery or invention that enables it. At first a few will experiment with the invention and growth will be slow. Next a point will be reached where widespread interest in the novel technology develops and growth will accelerate in what appears to be an exponential fashion. It is this part of the growth curve that futurists base their prediction on.

But as more is accomplished, room for improvement retracts and improvement becomes more expensive to accomplish. Eventually the cost of improving the technology exceeds the benefit achieved by the improvement and growth slows to a trickle. It is this leveling off that futurists do not incorporate in their models.

Growth is interrupted by catastrophe. Malthusian population explosions pause for pandemics and the massive death toll of wars. Growth is interrupted by alternate technology that solves the same problem less expensively. Diesel replaces steam. Transistors replace vacuum tubes.

The Google search engine provides a clear example of side effects. Larry Page made two conjectures: that the best order to present search results was to rank them according to their usefulness; that utility could be correlated by the number of existing links to each result. This resulted in a very successful search engine. Result owners wished to have their results presented earlier in the list. They found ways to increase the number of links. This lead to search engine optimization (SEO) which amounts to an arms race between Google, extending the ranking algorithm to account for existing SEO, and page owners, changing their strategy to account for changes in the ranking algorithm.

Futurists find themselves in a trap. Dramatic predictions lead to widespread readership. Dramatic predictions easily result from exponential extrapolation of trends.The only cost of being wrong is embarrassment. Embarrassment is avoided by predicting far enough into the future that you will not be remembered as making them when they fail to materialize.  Do you know who predicted flying cars in 2000, earlier in the 20th century? Neither do I, nor did I in 2000, when they failed to materialize.


I have not described all of the causes of the spectacular failure futurists, nor have I described their successes.

Glass in Blender

This discussion covers Blender 2.79. I assume you are comfortable with the user interface, know how to model, and have some understanding of the node editor and creating materials in Blender using cycles.



I posted a render of a flashlight to a Facebook group. The most challenging feedback was that the glass looked wrong. I have tried to improve my glass material, but I’m lost. Here is my story.

I made a photograph of a fountain glass in front of a window, sitting on lazy Susan, lit from the side by a 10000 lux full spectrum lamp, at night. Because I took the photo, I know the camera sensor, focal length, focal point, and exposure time.

photo of a Coke glass

Simple photo of a Coke glass

I then made correct scale models of the lamp, the window, the glass and the lazy susan, placing each in the positions they occupy in the photograph.

scale model of the scene

A scale model of the scene photographed above

Next, I positioned a blender camera in the same position as the real camera.

camera view

The view that will be rendered in blender

wire frame view

The camera view, with the models in wireframe

The objects are precisely modeled, even the thickness of the glass is accurate. Notice that the light is out of the field of view, but is reflected in the window.

I added the coke label, a dark wood texture to the table and a light wood texture to the lazy susan. Wood textures are from Poliigon. I selected wood colors that matched the objects, but didn’t model the several varieties of wood that make up the lazy susan.

I did not add dirt on the lazy susan or smears on the glass. I planned to get the materials and lighting right and then add those. This is where I hit snags. I rendered the scene using a studio lighting set up #16 HDRI from the Zbgy studio lighting pack.

studio lighting render

First render of the scene using a studio lighting HDRI and a basic glass shader.

(Render details: I left the camera at the default 35mm setting, since this matched the image closely enough.  I set a focal point at the bottom center of the glass and an Aperture of f1.8. I enabled Filmic color management with default settings, and denoiser with default settings. The resolution is 768 x 1024 @ 100%. For the test render, clamping was set to 1 for both direct and indirect. I used 512 samples.)

The first problem: lighting

I disabled world lighting and enabled an area lamp. The lamp was set to a blackbody temperature of 5500K and sized to match the light source of 23cm x 10cm diffuser. I calculated the strength by converting lux to wt/m^2 and setting the strength. The image was far too dark.  So I tuned the strength using the lazy susan as a guide. The light is somewhat brighter than in the photograph. In short, the scene lighting does not precisely match the real world.

scene rendered with scene lighting

The model rendered using the same lighting as the original scene

There are a few modelling discrepancies. The focal length isn’t precisely right, so the perspective distortion of the bottom of the glasses don’t match. The model glass has a thinner base than the original. There is only one Coke logo on the class and it is a slightly different size and position than in the original. The position of the lamp doesn’t seem to precisely match. It is not reflected in the window, nor is it reflected in the same place on the glass. [Note: I fixed some of this before doing the final render. It is left as a reader to determine which parts.]

Modeling Glass in Blender

Taking these into account, we arrive at the second issue, the crux of this post: The glass shader.  How can we improve it?

There are many things that the basic glass shader doesn’t do and there are many kinds of glass. I had collected three different glass shaders from various sources and rendered the scene with exactly the same setup, but with each of the glass shaders. As you can see, each shader is focused on particular aspects of glass and the renders are different from each other and from the basic glass shader.  

rendered with Hicks glass shader

The basic render using a glass material that Mike Hicks published on Facebook

Alexander Bräunig shader

The scene rendered using the Principled Glass Advanced from Alexander Bräunig

penfinity glass

A glass shader from a youtube tutorial  from penfinity

There are two approaches to attempting photo realistic glass in Blender. The first augments the glass shader to add features it is missing, or replaces the glass with a refractive shader.. A wide range of tutorials on this can be found by a Google search.

The second is to fake it. An excellent discussion of this approach can be found in Alexandrov’s Create Realistic Ice and Seriously Awesome Refraction. If you would like to explore this approach I recommend subscribing to Gleb Alexandrov on youtube and perhaps visiting his site Creative Shrimp.

Augmenting the basic glass shader.

How light interacts with a surface

I’ll keep the physics to a minimum, but there are certain terms that are useful. Here is the obligatory diagram

light paths on glass

Physics 101 light on glass

When light strikes a surface, it is split into up to four parts. It can be

  • absorbed: Any surface will absorb light. Absorption creates the color of a surface because not all colors of light are absorbed the same amount.
  • reflected: Some part of the light will be reflected from the object. When we see a surface, we are seeing the light that is reflected by it.
  • scattered: The rougher the object, the more light will be scattered
  • transmitted: If the object is transparent, some percentage of the light will pass through it. The light will bend as it enters the object and bend again as it leaves the object. The parameter that describes this is the Index of Refraction, IOR for short.

There is a problem with Blender’s model of light that makes modeling some aspects of light impossible. Blender’s nodes that use the IOR do not take into account that different wavelengths of light will have different IOR values at the same interface. This is called dispersion and is why you can’t model a prism creating a spectrum in Blender.

How blender models this behavior.

Blender introduced the principled shader in 2.79. Much of what I discuss next can now be modeled by a single principled shader. I am going to use the older method because I think the separate nodes make it easier to understand what is going on. I’m also going to ignore texture for now.

Blender divides reflection and scattering into two shaders. The diffuse shader models the scattering effect while the glossy shader models the reflection effect. Andrew Price of Blender Guru likes to describe materials as metal or non-metal, which he calls dielectric. Metals are perfectly reflective while dielectric materials are not. But even metals can be rough so Blender provides a mix shader so that you can model a material with both properties.

basic material

Before the principled shader, most materials started from this node configuration

Absorption is handled by the value of the color. The material absorbs all light, except for light of the specified color. It absorbs some of the specified color as well. A light color will reflect more of the light than a dark color of the same hue.

This model doesn’t handle transmission, however. For transparent material, we can switch to the glass shader. The 2.79 Blender manual says

The GlassBSDF node is used to add a Glass-like shader mixing refraction and reflection at grazing angles. 

and goes on to add

With caustics disabled, glass will miss shadows, and with filter glossy they might be too soft. We can make a glass shader that will use a Glass BSDF when viewed directly, and a Transparent BSDF when viewed indirectly.

and provides the glass shader most often shown in tutorials

glass with transparency

The glass material recommended in the Blender 2.79 manual

The glass shader handles reflection and refraction but will generate caustics. The thing to know about caustics is that Blender cycles renderer does a poor job with them and people often disable them in the render properties to avoid the noise they add to a scene.

The problem is that disabling caustics means that the glass won’t pass shadows from other objects. The transparent shader compensates for this.

The trick is how the glass and transparent shaders are mixed. In reality they aren’t. Either one or the other is selected by the nodes driving the Fac input of the mix shader. The math node, set to maximum will return either a 0 or a 1 depending on the output from the light path. When the fac is 0, the glass shader is used exclusively. when it is 1, the transparent shader is.

The manual has this to say about the light path node

Ray types can be divided into four categories:

  1. Camera: the ray comes straight from the camera.
  2. Reflection: the ray is generated by a reflection off a surface.
  3. Transmission: the ray is generated by a transmission through a surface.
  4. Shadow: the ray is used for (transparent) shadows.

Reflection and transmission rays can further have these properties:

  • Diffuse: the ray is generated by a diffuse reflection or transmission (translucency).
  • Glossy: the ray is generated by a glossy specular reflection or transmission.
  • Singular: the ray is generated by a perfectly sharp reflection or transmission.

The Light Path node can be used to find out the type of ray the shading is being computed for.

The material does this:
If the light is either a shadow ray or a diffuse reflection ray, then use the transparent shader, otherwise use the glass shader.

Oddly enough, disabling caustics and using this material makes the render less photo realistic in some ways. Making shadow rays transparent causes the render to lose the shadows created by the glass itself.

transparent glass

Using the glass material recommended in the Blender manual

A different way?

The glass shader has is suitable for many situation, but it doesn’t provide the controls needed for all cases. There is another approach to modeling glass materials. An alternative approach adopted by a lot of shaders is to mix a glossy node and a refractive node, using the Fresnel effect to control the mix

simple refractive glass

The basis of a family of shaders that do not use the glass and transparency shader as a basis.

basic refraction

A render using the basic refraction/diffuse mix

There are many ways to adapt the basic shader. For example, Mike Hicks and Alexander Bräunig use the glass shader instead of the refractive shader. The penfinity shader avoids the Fresnel node and instead uses the Layer weight node, mixing Fresnel and Facing outputs. The variation I chose for the render is from Stephen Woods. It mixes the Fresnel and Facing output, but used two copies of the Layer Weight node, allowing the blend to be set separately for both, making it more suitable for my final render.

Woods' simple glass

A simple glass shader from Stephen Woods on the Facebook Blender Nodes group.

The final render

The last render of the series, using Stephen Woods’ simple glass node

But wait, there’s more.

There are two pieces of glass in the scene, the window and the drinking glass. While they appear to both be made from the same kind of glass, it turns out that different aspects of glass are important in each, so I used two different glass materials.

Rendering glass requires close attention to color management, sampling, and light path parameters.  While these are outside the scope of this post, I will mention in passing that glass scenes tend to be noisy and require high sample counts to render well. All of the images in this post were rendered using 512 samples, except the last. At 4096 samples, it still has some noise.

What clamping you do, if any, especially direct clamping, has a major impact.

The number of bounces may have to be increased, since light passing through or reflecting from glass may affect how other objects look.

Blender Cycles is not very good at caustics, but they may be necessary. Carefully decide whether to enable them or not.


There is more than one way to model glass in Blender. You have to work around the shortcoming of the glass node if you use it.  If you have multiple glass objects in a scene you may need different glass materials for each, even if they all seem to be made from the same glass.

It is not possible to model photorealistic glass in Blender, but using a range of techniques will allow you to approximate it in a way that is appropriate to your scene.


In response to comments on Facebook, I changed the model to more accurately represent the way typical glasses are constructed and redid the render with Wood’s glass. I also rendered the model using the principled glass shader, for completeness.

updated model

This model is more typical for fountain glasses.

model 2 with principled shader

Exactly the same setup as the Woods glass version, with the principled shader dropped in as a replacement for the Woods shader