CDR Shader – Re‐Coloring, Dirt, Rust - Outerra/anteworld GitHub Wiki
CDR Basics
Outerra now has an advanced shader that allows you to assign colors to parts of your model, and has dynamic dirt and rust, as well.
To use advanced recoloring/weathering features with your model, three things are required:
CDR
map, where red channel is recoloring mask, green is dirt mask, blue is rust mask.- Albedo texture authored in a special way (see Texture setup for recoloring).
- In the material settings, shader needs to be set to any of the
recolor
family.
For specific use cases, such as complex assets that have overlapping UVs, CDR2
map that uses model's UV2 channel is also available. If any of the channel on CDR2
map is present, it takes priority over the normal CDR
.
Recoloring
There are 4 shaders that support recoloring and other features:
recolor8
(supports up to 8 colors), (also "r8" in this guide),recolor7
(supports up to 7 colors, preserves shadows) (also "r7" in this guide),recolor6
(supports up to 6 colors, preserves highlights as well as shadows), (also "r6" in this guide),recolor3
(most lightweight, supports 3 color channels), (also "r3" in this guide)
Texture setup for recoloring
Firstly, a mask needs to be created to define (all) parts of the texture that would be recolored. This mask should be put into the red channel of the CDR
map. Black parts of that mask would be unaffected, white parts (red, once is in the proper channel), would be treated by shader as recolorable.
Secondly, individual recolorable parts need to be defined on albedo map. That basically means that the part of albedo that doesn't use recoloring mask is treated as a normal albedo, and the part that uses it, is treated as essentially an ID map. The following colors should be used:
color | RGB values | Used by shaders |
---|---|---|
red | 255, 0, 0 |
r8, r7, r6, r3 |
green | 0, 255, 0 |
r8, r7, r6, r3 |
blue | 0, 0, 255 |
r8, r7, r6, r3 |
cyan | 0, 255, 255 |
r8, r7, r6 |
magenta | 255, 0, 255 |
r8, r7, r6 |
yellow | 255, 255, 0 |
r8, r7, r6 |
white | 255, 255, 255 |
r8, r7 |
black | 0, 0, 0 |
r8 |
Be aware that, when the same mesh has more than one color, there can be seams between them (it won't look ingame exactly as the original texture); look at the blue line between magenta and cyan, in this example (this is the most obvious one, but you may notice others as well). Planify your model carefully, to avoid having those colors together.
recolor8
shader gives us the greatest variety for our models, by handling all available colors.
By excluding black color in the list of those that can be colorable, recolor7
shader would, to some degree, preserve darker color gradients if present on albedo; by excluding also white color, recolor6
would preserve lighter tones as well. However, if such tones are meant to look like weathering, it is advised to keep to them to very minimum on recolorable parts when authoring those textures and basically treat them as color IDs only.
Here we can see how the look of the fibers in the fabric, can be enhanced with the use of these shaders.
recolor7: recolor6:
recolor3
shader can handle soft transitions, like the blured cammo texture in the rear canvas, in this example.
Material setup
In the visual material editor, select appropriate variant of recolor shader and plug in the textures, including CDR
mask.
After that, go to Recoloring tab. This will allow you to create a color table to assign various material properties for each color ID that you have assigned on your albedo map.
As well as albedo color, roughness and reflectivity could be modulated as well. 4 modes are available:
- Dielectric with modulated roughness
- Dielectric with forced roughness
- Metallic with modulated roughness
- Metallic with forced roughness
Use dielectric for most materials, and metallic for non-coated metal. If you have an existing roughness map that you wish to preserve, use option with modulated roughness and set Rg slider to 0.
Color tables are stored in the asset’s objdef
file and apply to all recolorable materials that the model has, if there are multiple. Make sure that if you have several recolorable sub-materials on your model, the albedo colors need to match across those materials (e.g. is you use red ID for the car paint on your exterior albedo, the painted parts on your interior texture need to use the same color as well).
Don’t forget to save the changes you made both in the material and in the Recoloring tab.
Dirt
Dirt map uses green channel of CDR map. At the moment, the amount of weathering the model has is controlled manually via Dirtiness
slider. Dirt uses 2 material values (light and dark), with shader producing a gradient between the two depending on the settings.
Dirt map authoring
The lighter the tone, the earlier that part of the model is to be covered in dirt. Use a value of 0 (totally black) for parts that you do not want to accumulate any dirt at all. If you wish parts of the model to become dirty only at very high Dirtiness
levels (about 0.99 - 1.0), the lowest texture color value for that is about 0.032.
Use that slider in Levels tool in Substance Painter for adjustment
It is advised to use the full range to ensure softer transitions, and have high contrast details along the surfaces, to ensure both colors are used all the time, avoiding uniform and monotonous surfaces, especially when using high dirt/rust values.
Dirt advanced setup / fine-tuning
There are several parameters that are available to fine-tune the look of the dirt on your model.
Those are:
- Color Set – a set of globally pre-defined material values for Dirt and Rust
- Dirt Opacity – maximum opacity of the dirt
- Dirt Band – a threshold between lighter and darker dirt, lower values mean more of the darker dirt and sharper borders, higher values mean more of the lighter dirt and smoother dirt distribution.
- Dirt (Initial) – a minimum
Dirtiness
level, leave as 0 if you want your asset as shiny and new by default.
Those parameters are stored in the model's objdef
per color variant.
Rust
Rust map uses blue channel of CDR map. Rust setup is almost identical to Dirt in terms of setup, except it doesn't allow to change its Opacity per model variant.
For assets that do not benefit from rust, e.g. some buildings, it could essentially be repurposed to serve as a second weathering channel, for example, for moss and algae, by using a profile that has green-ish color for Rust.
Dirt & Rust profiles
The colors and roughness values for Dirt and Rust are pre-defined using profiles. They are stored in dirt.cfg
and used globally.