Physically based rendering and blender materials
Physically based rendering in Blender has been a guesswork for some time. With 2.79 however comes the principled shader. It will help you to create accurate blender materials for cycles. However, there still seems to be some confusion on how it works. Let’s get a closer look at it and nail Physically based rendering once and for all.
Physically based rendering or PBR for short is a way for ray traced render engines such as cycles to accurately describe a material. It lets the artist focus on the artistic side to a larger extent and leaves out how to deal with more technical issues. This information is a set of guidelines and is not written in stone. It is here for you to get an idea of how PBR works with the principled shader. Once you understand it you can break and bend the rules to your will, but a good foundation to start from is better than to dive in without knowing how the shader reacts to different settings or texture map inputs.
Two different workflows
PBR can be divided into two different workflows. Within the realm of Physically based rendering you use one or the other. They both give the same result in the end. The difference is the texture maps that are used to describe the final material. These are the two workflows.
The new principled shader is geared towards the metallic/roughness workflow and that will be our focus here. It is the most common workflow but you should be aware that there exists another one as well. However specular/glossiness is not natively supported in Blender by any one single shader.
Physically based rendering texture maps
When dealing with the Metallic/Roughness workflow we have three specific texture maps to work with.
- Base color(Diffuse, Albedo)
- Roughness(or inverted glossiness map)
We also have a few that are also shared with the specular/glossiness workflow. They are the following.
- Ambient occlusion(AO)
For most materials, we are concerned with the first set of maps and the normal map. The height and AO maps are optional. With these four maps we will be able to create a lot of the materials that we see around us every day. Before we talk more about maps however, let us first take a brief look at fresnel followed by color spaces.
Fresnel and specular
What is fresnel? First of all the pronunciation is with a silent s. Second, it is determining the falloff of specular from the viewing angle of 0 degrees to the edge of an object. Fresnel at a 0 degree angle is also referred to as F0. This is a property that all materials have.
The most clear example of this is when you are standing at the edge of a calm lake and you are looking down and you can see through the water clearly, but when you look in the distance the water becomes more and more like a mirror. This is fresnel and when viewing at a 0 degree angle the specular varies heavily depending on if you are looking at a metal or a non-metal material.
If we are looking at a metal straight on the F0 is between 70-100% depending on what metal we are looking at. For non-metals, this value is between 0% and 8% in most cases. At the edge of the object the specular is almost always at or near 100%. In the case of looking at a sphere it becomes clear. The edges will become more and more specular as its surface turns away from us.
Linear color space vs SRGB
Let us deal with the color space stuff now. The computer stores images in linear space. This means that there is an equal amount of color change between every shade from black to white. However, this is how the computer reads data, our human eye does not see color this way. So in order to save space and not send data to the screen that humans can’t see, we encode the data to give more space for color information in the ranges that we can see. This encoding is also called gamma correction.
So how do we see color? Well, what you need to know is that the monitor outputs color in SRGB color space. SRGB color space is adjusted so that we make use of more color space in the ranges that we can actually see. This means that before the image is sent to your screen the computer encodes the linear image to SRGB so that we can see a richer image.
Top gradient shows the linear color space as humans see it. This is then encoded to srgb for a more smooth gradient.
In Blender, when we add an image texture to our cycles material we have the opportunity to decide if the image should be converted to srgb before the node sends the image away as input for the next node to interpret. This is the default behaviour. However if we change the image drop down menu from color to non-color data we tell the node to not gamma correct the image, just send it over to the next node as it is in linear space. This is useful because all the maps that are not base color should be non-color data. They are not there for our eyes to see but for the shader to know what parts of the material does what. It is there for the computer to read, and the computer reads color in linear space.
The general rule becomes: Set all your texture maps to non-color data except the base color.
If you want to create the encoding yourself in Blender you can use the gamma node and set it to a value of 2.2. It is not exactly the same as the srgb encoding but it is so close that you probably can’t see a difference.
Metals and the principled shader
Now when we know a bit about color spaces and fresnel we will continue on with the inputs of the principled shader.
If we deal with a fully metallic material we set the metallic slider to 1 and no texture map is needed. Same goes for materials that is non metals. Set the slider to 0 and you are good to go. For any material that requires a combination you will need a texture map to tell Blender what areas of the material is metal and what is not. This map should be grayscale set to non-color data.
You can also set this to any value in between 0 and 1 but that will create a material that does not exist. Sometimes this can be useful though. Imagine that you are creating a metallic surface that has a dust layer on it, then this value can be tweaked to something in between to simulate the dust. It works but it is not accurate. You can also use gray values to blend between a metallic and dielectric material where their edges meet.
The metallic input also dictates how other parameters of the principled shader behave. When the input is set to 1 the specular slider has no effect. Same goes for specular tint. Changes to these inputs makes no difference. Instead, the specular data is coming from the base color map. I will repeat that. Specular data for a metal using the metallic/roughness workflow in a physically based rendering scenario will come from the base color map.
The base color map will still be set to color data even if it is used to determine specularity of metals. It is still also determining the color or specular tint if you will. Metals has no diffuse aspect to it so it makes sense to switch the behaviour of the base color input for metals. After all, it contains three times as much data then a grayscale map.
Most real world metals has a reflectance value between 70-100% at Fresnel 0. For us that means that the value of any pixel in our base color map should have a value of around 0.7 or higher. If we have a color texture map as input it means that the pixels should be in the brightest 30% in srgb color space.
If we input a color ourselves using the color wheel widget to set a solid color we will have to look at the hex values. The rgb and hsv set of sliders are in linear space so the values won’t be correct but the output will. This is not very convenient however so i usually stick to the hsv sliders and for metals I don’t let the value slider go below 0.7. The accuracy of this, well, good enough for me.
If you want real consistency however you should look up the correct colors for any given metal that you want to recreate.
Dielectrics and the principled shader
Now let’s move the metallic slider to 0. We are now in the realm of dielectrics or non-metal materials and the specular slider is in full effect!
However, we are in the metallic/roughness workflow and the specular input here works very different from the specular/gloss workflow and how we used to work. The input slider goes from 0 to 1 but you can set it to values higher than 1 by typing in the value. This 0 to 1 range is mapped to 0% to 8% specular. In the default setting of 0.5 we therefore have 4% specular. This is the most common range of specular for dielectric materials and in most cases the default 0.5 value does not need to change. Not very exciting. The slider is more of an artistic tool that you can tweak to squeeze some extra “oh yeah!” out of your material. It is not meant to create a 100% specular metallic. That we have the metallic slider for and when working with metals the specular is in the base color as we have learned.
Over to the base color. Now this value has nothing to do with specular for non-metals and is pure reflected color. Since we don’t want this to contain light or shadow information we should not let the image contain pure black or pure white. Try to leave the darkest pixels about 10% lighter than black and the lightest pixels about 5% darker than white in srgb color space for your base color map.
So, this leaves us with the roughness and normal maps.
Normal map and roughness
Now we will leave the realm of technical terms and head into the artistic mist of “it depends”, “tastes” and other interesting stuff that can’t be defined. Don’t be fooled though, we are still talking about pyhsically based rendering.
We start with the roughness map. This is the most artistic map and can be used to tell the story of your object. You can add scratches, dust, fingerprints or water vapor just to name a few. There is no real rules here other than experimenting and making the best combination of properties that will tell the tale of what the object has been through. It is a grayscale map that will determine no roughness at black or 0 and full roughness at 1 or white.
The normal map is often mistaken as meaning height information. But the normal map actually contains angle data. It determines the direction in which an incoming light ray will bounce of in. The result is however similar to height information in that it simulates geometry changes. It is another artistic map that helps to create more detail in an object that is way more efficient than using real geometry. Pipe it through a normal map node and into the normal input of the principled shader to use it. It can also be combined with height information from a height map using the bump node.
The other inputs
That is a mouthful of physically based rendering and blender materials with the new shader. Let’s take a quick look at the rest of the inputs before we move over to the summary. These are specific for special types of material like skin, carpaint, fabric or glass.
We start with the sheen and sheen tint. Sheen tint only has an effect if sheen is not 0. It is intended to help simulate cloth. It adds a soft white reflection around the edges. The sheen tint mixes in the base color into the reflection. This is useful when trying to make a cloth material.
The Anisotropic input is used to stretch the reflection of an object. Think of a brushed metal with a circular pattern such as the underside of a frying pan. Instead of having a normal map or geometry to simulate the circular pattern that gives it the stretch you can turn this input up to simulate it. The Anisotropic Rotation dictates the reflections rotation and at the bottom of the shader you have a tangent input that also can be used to affect the rotation in a more precise manner by inputting vector data. Both the tangent and anisotropic rotation hs no effect if anisotropic is at value 0.
Next we have the clear coat, clear coat roughness and clearcoat normal inputs. These are here to add an extra layer of specular on top of the material. Think of car paint that has these deep reflections. The clearcoat roughness is there to give this layer its own roughness and same goes for the normal. In a lot of cases the clearcoat normal is there so that you can input the same normal map into that input as you ordinary normal input. But in very rare cases you may want to have different normal maps for the two layers. Same thing here, the clear coat roughness and clear coat normal has no effect if the clear coat input is set to 0.
The IOR input only has effect if used together with the transmission input. The transmission input allows you to create glass and ice materials with the principled shader. The IOR will dictate the change in angle for lightrays going through the object.
Lastly you have the subsurface scattering(SSS) inputs that helps to create, you guessed it, subsurface scattering. It uses a different method for calculating subsurface scattering than the older SSS shader so the results will differ slightly from the regular SSS. But it is here to make sure that we can use this one shader to create the largest amount of materials possible without having to use different shaders and combinations. You also guessed right when you assumed that the subsurface radius and subsurface color has no effect if the subsurface input is set to 0.
There are of course other areas to consider as well like lighting and post processing. You should also use the filmic color management in Blender to make sure that you have a wider dynamic range available for more realistic renders. If you find any errors, please contact me to let me know so that I can make a change. Physically based rendering is important not only for realism but for consistency as well.
Anyway, what are the important values to take from this?
- You should use non-color data for all your textures except base color for both metals and nonmetals
- For metals, keep your color values in the lightest 30% srgb color space in the base color map.
- For dielectrics keep the color values above the 10% darkest and below the 5% lightest for the base color map.
- In most cases the metallic input is either 1 for metals or 0 for dielectrics. Seldomly much in between.
- When the metallic input is 1, the specular has no effect. The specular is instead calculated from the base color.
- Roughness is the most artistic map, use it to tell the story of your object
- The normal map is angle data for outgoing light rays and not height information.
Below is a list of links to some of the sources for this article. If you want more, check out our other articles and tutorials. A handful is linked below.