Shaders

RED3 shaders (w2mg)

What are shaders?

Every visual asset in REDengine 3 uses a specific shader, designated by REDengine as W2MG (.w2mg/Witcher 2 material graph) files. Even meshes "without a shader" are in-fact using a debug shader such as debug.w2mg. Shaders are the most basic expression of a surface, ranging from glass, skin, concrete, and steel. Each shader contains a combination of constant hidden-variables, and exposed variables for artists to tweak. For example, all skin exhibits some similar properties such as subsurface scattering so there is no reason to expose this; artists cannot use the skin shader without subsurface scattering. However skin color can vary dramatically, so these parameters are exposed to the artists using textures. Artists are able to create "instances" of shaders called Material Instances which contain localized variations of the textures and properties exposed by the base shader.

Common Shader Usage

We do not have official documentation from CDPR about how shaders are used by artists. Thus any 2d/3d artist is looking at hundreds of black-box shaders with unknown usage. This is extremely demotivating for anyone looking to bring new assets to life with REDengine. The following list of tables is an attempt to make life easier for artists by using the community to document commonly used shaders.

Understanding the Documentation

The name and path of each shader will be documented by the header.

Next we are using a table for each texture parameter with the exact name listed by CDPR in the w2mg file, how REDengine uses each specific RGBA channel, and the usable range of the channel if not 0-1/0-255. When applicable, vertex color properties will be listed underneath the texture table with a similar format. Scalar, vector, color, and other properties will follow with their own unique description table. An asterisk (*) is used to notate some degree of uncertainty, or need for more independent testing.

pbr_std_tint_mask_det

engine\materials\graphs\pbr_std_tint_mask_det.w2mg

Texture Channels

Red

Green

Blue

Alpha

Diffuse

Color

Color

Color

Transparency

Normal

Normal

Normal

Normal

Roughness

Tintmask

Ambient Occlusion

Tint

Detail Mask (128-255)

None

Properties

Description

SpecularColor

RGB value to assign specular highlight

DetailNormal1

1 of 2 procedural normal map detail overlays

DetailTile

X/Y tiling values for DetailNormal

DetailRotation

Rotation values for DetailNomal

DetailRange

Distance at which DetailNormal is applied to mesh

Roughness_min/max

Clip values to add a global min/max to roughness texture

AOPower

Multiplier for Ambient Occlusion

Notes

  • Extremely common for character assets

  • Uses EnableMask flag to create alpha clipped transparency mask from diffuse texture

pbr_std_tint_mask_2det

engine\materials\graphs\pbr_std_tint_mask_2det.w2mg

Texture Channels

Red

Green

Blue

Alpha

Diffuse

Color

Color

Color

Transparency

Normal

Normal

Normal

Normal

Roughness

Tintmask

Ambient Occlusion

Tint

2 Detail Masks (0-0.5/0.5-1)

None

Properties

Description

SpecularColor

RGB value to assign specular highlight

DetailNormal1

1 of 2 procedural normal map detail overlays

DetailNormal2

2 of 2 procedural normal map detail overlays

DetailTile1/2

X/Y tiling values for DetailNormals

DetailRotation1/2

Rotation values for DetailNomals

DetailRange

Distance at which DetailNormal is applied to mesh

Roughness_min/max

Clip values to add a global min/max to roughness texture

AmbientPower

Multiplier for Ambient Occlusion

Notes

  • Extremely common for character assets

  • Uses EnableMask flag to create alpha clipped transparency mask from diffuse texture

  • Based on pbr-std-tint-mask-det

  • The tintmask texture packs 2 maps into the blue channel, one map from values 0-127 and another from 127-255. The "zero value" for both textures is at the midpoint, while using values closer to 0/255 will increase the detailmap strength.

pbr_std_tint_mask_2det_fresnel

engine\materials\graphs\pbr_std_tint_mask_2det_fresnel.w2mg

Texture Channels

Red

Green

Blue

Alpha

Diffuse

Color

Color

Color

Transparency

Normal

Normal

Normal

Normal

Roughness

Tintmask

Ambient Occlusion

Tint

2 Detail Masks (0-0.5/0.5-1)

None

Properties

Description

SpecularColor

RGB value to assign specular highlight

DetailNormal1

1 of 2 procedural normal map detail overlays

DetailNormal2

2 of 2 procedural normal map detail overlays

DetailTile1/2

X/Y tiling values for DetailNormals

DetailRotation1/2

Rotation values for DetailNomals

DetailRange

Distance at which DetailNormal is applied to mesh

Roughness_min/max

Clip values to add a global min/max to roughness texture

AmbientPower

Multiplier for Ambient Occlusion

FresnelPower

Fresnel multiplier

FresnelStrenght

(misspelled by CDPR) Fresnel multiplier

Notes

  • Uses EnableMask flag to create alpha clipped transparency mask from diffuse texture

  • Based on pbr-std-tint-mask-2det

  • The tintmask texture packs 2 maps into the blue channel, one map from values 0-127 and another from 127-255. The "zero value" for both textures is at the midpoint, while using values closer to 0/255 will increase the detailmap strength.

  • Uses "fresnel" values to add extra fresnel effect to the mesh. Read more about fresnel here.