INTRO
We all know that Tight Deadline and High Quality are rarely best buddies. Often times, in the final stages of a project we just do not have enough time to detail every last bit and therefore we sometimes end up with some flat looking images. What we are usually missing will be the topic of this article - detailed and realistic shaders.
THE IDEA
We already have a material library that acts as a great base for creating complex materials, however, we are still missing the complex materials themselves. Of course, we can further populate this library with some detailed shaders - a process that will take a considerable amount of time before it starts bearing fruits. Here we are going to discuss a slightly different approach - creating a map instead of a material template.
THE THEORY
SURFACE PROPERTIES FOR DUMMIES
All surfaces have physical defects, traces of wear, accumulation of dirt particles, etc. Obviously, we are working mostly with surfaces that exist indoors and the "weathering" on these is considerably less. In addition, we don't want to make our objects look dirty - the effect we are striving for is a very delicate wearing effect which you will find on every object in the house no matter new or old. In other words, objects need to appear clean but not perfect. We would like to also create a template, something that can be equally used across all objects and scene scenarios and therefore will try to make this as simple and as versatile as we can.
The main goal of this template is to better the "big" picture. Quite a few material properties affect this but if we need to concentrate on only one, that would be the reflectance of objects - more precisely the highlight of their reflections where details are most visible. In terms of VRay materials, this means that we are going to mostly tackle the Reflection Glossiness channel (mostly but not only). The glossiness channel, in general, represents surfaces micro details - in other words, this is a bump map on a micro level and even polished surfaces have uneven details on this level. Everything else you see breaking the highlight of objects is mostly a result of things like oils and dirt accumulating over time.
The foundations of the template are these most common surface imperfections (naming conventions used are from the actual template you will see below):
- GENERIC_DIRT – this layer represents the micro-details of a surface and most of the dirt accumulated from general use. Acts as a subtle reflection breaker with no exact details visible to the eye.
- GENERIC_SMUDGE – this layer represents the thin layer of oil accumulated over time – dirt wipes, fingerprints, grime.
- FINGERPRINTS – this layer contains mostly fingerprints and smudges from hands, separated for more control
- MICROSCRATCHES – we don’t want to add actual large scratches as this might make our objects look a bit too old and used, however, we can add some micro scratches usually visible on polished surfaces, metals and in general glossier objects
- DUST – self-explanatory
- FLOOR_SMUDGE – this is one especially for floors as you won’t be seeing fingerprints there but more like footprints and much larger wiping residue. Will put this after GENERIC_SMUDGE layer for a more logical order (you would generally use one or the other, never both of them at the same time).
THE MAPS AND THE MAP TREE
This might look scary to some at first but it’s actually quite simple. However, to be able to use it correctly and fully we need to understand how everything works and why is it there in the first place.
VRayHDRI maps: all bitmaps that we use are loaded in VRayHDRI maps instead of the usual Bitmap map. The blur value of all textures is set to 0.01 to disable filtering for sharper results (especially important for bump and normal maps).
VRayTriplanarTex maps (Fig. 01): After the VRayHDRI map bitmaps go through a VRayTriplanarTex map from where we control their size and mapping. As VrayTriplanarTex works with real-world mapping using a form of box mapping and doesn’t require any mapping coordinates on the object it’s applied to, we can be sure that no matter where we use it we will get the same results. The Blend value used across is 0.2 – kept at low so we don’t lose too much detail in the transitions. There are a few things that differ between some of the VRayTriplanarTex maps:
- The use of different mapping space: for most the mapping space is set to Local Object, however, maps that might need to go over a surface compiled of many different (detached) objects like wooden floors or ceramic tiles, for example, are set to Reference to another node. This means that there won’t be an individual map applied to every single object but instead, the map will treat all objects as one and defects will continue seamlessly in between them. The latter method is in fact only used for the GENERIC_DIRT and FLOOR_SMUDGE layers.
- Random texture offset and rotation – self-explanatory. Again used on all maps except for the GENERIC_DIRT and FLOOR_SMUDGE layers.
Fig. 01: VRayTriplanarTex used for most surface imperfections
Output maps (Fig. 02): After the VRayTriplanarTex all maps go through an additional Output map where we control and fine-tune their contrast. All base maps are intentionally left with no borderline black or white values to leave more room for additional contrast adjusting.
Fig. 02. Output maps are usually used to boost the contrast of the base textures
Composite maps (Fig. 03): These are used across to blend between the different layers of imperfections. Various opacity values and blending modes are used for achieving correct appearance.
Fig. 03. The Reflection Glossiness composite map
The BASE_MATERIAL is a placeholder. This is where the material we want to “upgrade” will go replacing the plain one. We have 3 components that need taking care of: Reflection Glossiness represented by a composite map, Anisotropy Rotation, again a composite map, and Bump represented by an additional VRayBumpMtl. The first two will be going into their corresponding slots into the material we are editing, while the material itself will need to be connected to the Base mtl slot of the VRayBumpMtl. We would then need to apply the VRayBumpMtl to our objects as this will carry our additional bump (adding on top of what we already have, if we do, in our base material).
Fig. 04. All of the maps needed for controlling the appearance of the shader - blue for the glossiness, green for the anisotropy and red for the bump controls.
The REFLECTION_GLOSSINESS composite map: This is where most of the magic happens. We have here all the layers I’ve mentioned previously with the addition of a VRayColor map acting as a base which will control the general glossiness of our object.
- BASE_GLOSS layer: a VRayColor map which is used to replace the Reflection Glossiness value. Usage instructions in "Setting up the maps" chapter below.
- GENERIC_DIRT layer: this layer is set to Overlay mode. This means that values above mid-grey (128, 128, 128 RGB) will lighten the layer below and values below will darken it. For this to work correctly the map used is first colour corrected in Photoshop to be in the middle of the histogram (all its colour values are around mid-grey). The map doesn’t have much contrast as it’s meant to just break the reflection glossiness without introducing any particular detail.
- ALL OTHER layers: these are all black and white maps which are set to Darken mode. This mode darkens the values of the layer below only if these values are brighter. If these are darker they don't get darkened additionally (like they would with Multiply mode). This means that the more matte a surface gets, the fewer details like fingerprints and wiping residue will be visible.
The ANISOTROPY_ROTATION composite map: fingerprint traces are actually a thin layer of oil that is left every time we touch a surface. Similarly, dirt wipes are a combination of water and oil residue left from spilling something while cooking for example. Light rays change their direction while passing through this thin oil residue layer before hitting a surface. Highlights start to look a bit distorted and we can somewhat fake this effect by using our GENERIC_SMUDGE and FINGERPRINTS layers to create a map for the Anisotropy Rotation.
This composite map is constructed in a similar way as the REFLECTION_GLOSSINESS, however this time the BASE layer comes last, on top of the detail layers GENERIC_SMUDGE and FINGERPRINTS. This is done in order to have separate control between the blending of these detail layers as, if they are both turned on, we need to mix them without affecting the general anisotropy rotation value. Hence, the layer mode of the second layer is set to Average. The VRayColor map is used again to control the Anisotropy Rotation value. Usage instructions in "Setting up the maps" chapter below.
The VRayBumpMtl: many of the materials we use usually come with a pre-made bump map. Therefore, a VRayBumpMtl is used to add bump on top of any existing one. The bump comes from a composite bump map and a Normal map. The composite map has two Noise maps – one for large scale and one for low scale soft bumps/deformations. On top are the GENERIC_SMUDGE and FINGERPINTS layers which are firstly inverted through Output maps and then set to Screen mode so they will appear to stick out/be on the surface. These layers are set at very low opacity for a subtle effect. The composite map goes into a VRayColor2Bump map to control the amount of bump (some additional control is still available from the layers opacity value).
IN PRACTICE
GENERAL WORKFLOW
01. Import the Dirt Map Template (R:\02_ASSETS\00_DIRT_MAP_TEMPLATE\)
02. Instance it in a new clean mat editor tab
03. Pick a material that you would like to adjust in the same tab
04. Select and copy all following parts of the map template (Fig. 04):
- REFLECTION_GLOSSINESS composite map + VRayColor map
- ANISOTROPY_ROTATION composite map + VRayColor map
- BUMP composite map + VRayColor2Bump map + NORMAL_BUMP map + VRayBumpMtl
05. Detach the BASE_MATERIAL from the VRayBumpMtl and replace with the new material
06. Adjust the rgb multiplier of the VRayColor map into the REFLECTION_GLOSSINESS map to match the Reflection Glossiness value of the new material OR replace the VRayColor map with the Reflection Glossiness map of the new material. Plug the composite map into the Reflection Glossiness slot
07. Plug the ANISOTROPY_ROTATION composite map into the Anisotropy Rotation slot and adjust the rgb multiplier of its VRayColor map to match the value set in the material (if the value is 0 leave the VRayColor at default) OR replace the VRayColor map with the Anisotropy Rotation map of the new material
08. In the material settings enable anisotropy by setting a value between 0.1-0.5 (value dependant on surfaces glossiness, more info below)
09. Select the object/objects the new material is applied to by using the Select by material function of the Mat Editor (remember that you need to open all object groups (use Open Reclusively) if you have your material applied to multiple objects located in groups) and apply the VRayBumpMtl instead of the original material.
10. Customize your material – almost every layer is turned off by default. Think about the type of material you have and what object it is applied to – is it a worktop, a glass, a floor, etc. and enable the correct maps.
11. Edit another material – you need to instance the maps to optimise the workflow and things might start to look a bit messy when you have even a few materials in your view. That‘s why you can specify a tab only for doing material changes where you will keep the template and adjust every material individually. After you‘ve finished a material you can delete it from the tab and pick another one to work on.
Check the video below to see the workflow in action:
SETTING UP THE MAPS
All of the details we are adding primarily exist in the Reflection Glossiness and are then partially distributed over to the Anisotropy Rotation and BumpMtl. Almost all maps are turned off by default. Therefore, you should first think and decide what type of surface you’re working with, enable the desired effects in the Glossiness and then follow through the other maps (check the next chapter "Map links"). Here are some tips on how and when you should use each effect for maximum realism/performance:
- VRayColor Map - there are two of these maps used in the template and they both replace numeric values of the material with colour values.
VrayColor map (gloss): This map controls the glossiness amount. You have two options with this map:
• If your material only has a glossiness value (no map in the glossiness slot) of 0.78 for example, you should type this value into the rgb multiplier of the VRayColor map. (Fig. 05)
• If your material already has a glossiness map applied, you can remove the VRayColor map and plug the glossiness map into the BASE_GLOSS slot of the composite map.
VrayColor map (anisotropy): This map controls the anisotropy rotation value. This is a rotation value that goes from 0 to 360 degrees. In colour values pure black equals 0 degrees and pure white equals 360 degrees. Here again we are working with the rgb multiplier of this map which has values from 0 to 1 (black to white) which means that a value of 0.5 equals 180 degrees, a value of 0.25 equals 90 degrees, etc.
This map needs a bit more attention to be used correctly. For materials that do not have anisotropy enabled the map should stay turned off - the roration will be coming only from the detail maps below. As these maps have very high contrast there will be no evident rotation and objects will appear not to have any anisotropy and rotation. However, in cases where we have anisotropy enabled (mostly on metals and for values above 0.3) the map should be turned on and then, as mentioned above, the rgb multiplier needs to be adjusted to match the anisotropy rotation of the material. This map is set to 95% opacity so it can get a little bit of the detail maps below and break the anisotropy effect.
- GENERIC_DIRT – This one should be always on as it acts as a general reflection breaker so it can be used for all surfaces.
Base Opacity (gloss): 100 – you should be safe to keep this at 100. For very matte surfaces it might introduce more contrast in the highlight than needed and can be lowered to 50.
TIP: For very glossy surfaces you can add a bit more contrast to this map. All you need to do additionally when doing the initial shader setup is to duplicate the Output map for this layer with the rest of the map tree. Then make a simple s-curve inside and adjust contrast as desired.
TIP: For large surfaces like floors or worktops you can also duplicate the VRayTriplanarTex map of this layer and change the size from 50cm to 100cm so you won’t be getting as much repetition.
- GENERIC_SMUDGE – Used for both small and large-scale objects.
Base Opacity (gloss): 5 – opacity can vary between 5 for glossy objects (0.85-1) and 10 for matte objects (up to .8). Remember that if the effect is too dominant you can always check the map library and choose a less busy texture.
Base Opacity (anisotropy): 100 – Opacity should stay at 100 at all times. For all objects that do not have any anisotropy, this map is used to introduce a thin layer of oil. The map has values between 0 and 255 rgb and will produce generally round, but distorted highlights (amount of distortion is dependant on the Anisotropy value of the material).
Base Opacity (bump): 1 – should be left as is. Can be turned off for larger objects/objects that won’t have close-ups. The main purpose of this one is to sharpen the smudge details.
TIP: For wall tiles, you can duplicate this map back to its VRayTriplanarTex and change the mapping space to Reference to another node(only in case your tiles are individual objects, no need to do this if they are part of the same object). This needs to be done in order for the texture to appear over the whole surface of the tiles instead of on every individual tile separately.
TIP: For large surfaces like worktops and tables you can raise the size of this map to 50-60cm. Just remember to duplicate the VRayTriplanarTex (and the Output map after it, of course) with the rest of the map tree when setting up the initial shader. With this size, you can use it even for floor surfaces for an additional detail in the glossiness.
- FLOOR_SMUDGE – used only for floor surfaces be it wood, tiles, concrete, etc.
Base Opacity (gloss): 10 – Setting a higher value won’t be necessary in most situations, unless for very matte floors.
- FINGERPRINTS – should be used only for small objects like cups, glasses, vases, kettles, etc. For close-ups can be used for worktops but with lowered opacity – beware of repetition. Can be turned off for materials with less than 0.65 glossiness value
Base Opacity (gloss): 5 – same as GENERIC_SMUDGE
Base Opacity (anisotropy): 100 – same as GENERIC_SMUDGE
Base Opacity (bump): 1 – same as GENERIC_SMUDGE
- MICROSCRATCHES – should be used only for small objects and cameos/close-ups. Should be used for polished (glossy) surfaces like metal, plastic, porcelain, glass. Can be used also on more matte metals.
Base Opacity (gloss): 20 – should be left at default. Can be raised if more scratches are needed to be visible.
Base Value (bump): 0.1 – no need to be adjusted under any circumstances.
- DUST – should be used only for cameos/close-ups
Base Opacity (gloss): 50 – can be left at default at all times.
MAP LINKS
As most maps affect different parts of the material properties you need to remember that if you turn on one map in the REFLECTION_GLOSSINESS composite map, you need to follow what else it is affecting. Here are all the map dependencies to make it easier:
- GENERIC_DIRT = REFLECTION_GLOSSINES
- GENERIC_SMUDGE = REFLECTION_GLOSSINES + ANISOTROPY_ROTATION + BUMP
- FLOOR_SMUDGE = REFLECTION_GLOSSINES
- FINGERPRINTS = REFLECTION_GLOSSINES + ANISOTROPY_ROTATION + BUMP
- MICROSCRATCHES = REFLECTION_GLOSSINES + NORMAL_BUMP
- DUST = REFLECTION_GLOSSINES
USING THE MAP LIBRARY
If you would like to have some variety in your reflection maps there is a small material library calibrated to work with the template. The maps are named and ordered accordingly. To use a different map you need to copy the VRayHDRI map corresponding to the texture you would like to change (when initially duplicating the map tree). Then just browse through the library and select a different one.
The library can be found in R:\02_ASSETS\00_DIRT_MAP_TEMPLATE\MAPS
ADDITIONAL TIPS
1. You should not copy/use the ANISOTROPY_ROTATION composite map if your shader has a Glossiness value below 0.65 as the effect won’t be noticeable enough to justify the slower render time.
2. Add the template while at the final Detail Stage of a project as it slows down render times considerably.
3. Since you’re going to be picking individual materials one by one to apply the template you might as well check if they are up to date (as some shaders were created with an older workflow). Things to check
- BDRF – should be set to GGX. When you change it you should also match the glossiness value. Play with the Tail falloff if necessary (usually higher for matte surfaces and lower for glossy surfaces)
- Cutoff (Options tab) – should be set to 0.001
- Glossy Fresnel (Options tab) – should be always turned on
- Affect Shadows – for transparent objects this should be on
- Max Depth (reflections/refractions) – think how much would your shader need
CASE STUDY / EXAMPLE
...