# Multilayered: Cyberpunk's supershader

## Summary

**Published:**\
**Last documented edit:** Oct 15 2024 by [mana vortex](https://app.gitbook.com/u/NfZBoxGegfUqB33J9HXuCs6PVaC3 "mention")

This page describes Cyberpunk's multilayered supershader.

### Wait, this isn't what I want!

This wiki contains multiple guides about editing multilayered materials, such as:

* For editing .mlmask files: [custom-multilayermasks](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/textures-and-luts/custom-multilayermasks "mention")
* For editing .mlsetup files:
  * Check [this video guide](https://youtu.be/ont3VGbnZ3g) for editing it in Blender
  * [changing-materials-colors-and-textures](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/items-equipment/editing-existing-items/changing-materials-colors-and-textures "mention")
  * [recolours-and-refits](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/items-equipment/recolours-and-refits "mention") -> [r-and-r-colour-editing](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/items-equipment/recolours-and-refits/r-and-r-colour-editing "mention")
  * [textures-and-materials](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/vehicles/boe6s-guide-new-car-from-a-to-z/textures-and-materials "mention")

## Why can't they use textures?

Everyone asks this question in the beginning, but you're only a single epiphany away from a change of mind. The multilayered shader can pack up to 20 layers of texture into a single file! Read on to find out how it works.

## About

A significant portion of assets for Cyberpunk 2077 leverage the complex multilayered.mt supershader. The supershader has several different component files which are used to create masks to blend procedural textures without baking them. You can read more about this technique in [this documentation](https://magazine.substance3d.com/cyberpunk-2077-a-world-full-of-substance/) by CDPR Technical Art Director Krzysztof Krzyścin.

{% hint style="info" %}
While the multilayered supershader is very common, there are hundreds of other non Substance-style shaders, some with traditional baked PBR textures.
{% endhint %}

## Composition

{% hint style="info" %}
For a list of shader properties in multilayered.mt, see [https://github.com/CDPR-Modding-Documentation/Cyberpunk-Modding-Docs/blob/main/for-mod-creators-theory/materials/multilayered/broken-reference/README.md](https://github.com/CDPR-Modding-Documentation/Cyberpunk-Modding-Docs/blob/main/for-mod-creators-theory/materials/multilayered/broken-reference/README.md "mention")
{% endhint %}

The multilayered shader is composed of three distinct parts:

1. **Layer Masks** | Mask textures that control where each surface is visible\
   [**.mlmask files**](#what-is-the-mlmask)
2. **Layer Definitions** | Controls procedural effects such as tiling or color for each layer\
   [**.mlsetup files**](#what-is-the-mlsetup)
3. **Layer Surfaces** | Links PBR textures to create numerous pre-defined visual surfaces\
   [**.mltemplate files**](#what-is-the-mltemplate)

{% hint style="info" %}
For editing mlsetup files, you'll want to use the [MlSetupBuilder](https://wiki.redmodding.org/cyberpunk-2077-modding/for-mod-creators-theory/modding-tools/mlsetup-builder) ([download](https://github.com/Neurolinked/MlsetupBuilder))
{% endhint %}

## What is the mlmask?

**MLMASK** files are the core element of the substance-style integration. These files contain an array of up to 20 textures which are used to control the blending between pre-defined surfaces called **mltemplates**. These mask textures are more-or-less 1:1 with substance-style layer masks.

![Demonstration of how mlmask files are used to mask meshes. Each mask will apply to a separate material layer.](https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-727ad3bcc1e73d0ae7c06213a6d8b0de11217b20%2Fmlmask_demo.gif?alt=media\&token=d83a8e12-8b23-4858-9e3a-b4e4090ee54d)

As shown above, each mesh using the multilayer shader uses a unique **mlmask** file that is hand authored by CDPR artists. To take effect in game, each mask file is linked by the **mlsetup** file.

## What is the mlsetup?

**MLSETUP** files are fairly self-explanatory when considering the name, multilayer setup. These files correspond with an **mlmask** file and are responsible for setting up parameters for each layer from the mlmask. Each layer within an mlsetup contains information very similar to materials or shaders.

To edit .mlsetup files, it's recommended that you use the [mlsetup-builder](https://wiki.redmodding.org/cyberpunk-2077-modding/for-mod-creators-theory/modding-tools/mlsetup-builder "mention") software.

{% hint style="info" %}
For a definition of the properties, see [https://github.com/CDPR-Modding-Documentation/Cyberpunk-Modding-Docs/blob/main/for-mod-creators-theory/materials/multilayered/broken-reference/README.md](https://github.com/CDPR-Modding-Documentation/Cyberpunk-Modding-Docs/blob/main/for-mod-creators-theory/materials/multilayered/broken-reference/README.md "mention").

For a guide on how to edit one, check [r-and-r-colour-editing](https://wiki.redmodding.org/cyberpunk-2077-modding/modding-guides/items-equipment/recolours-and-refits/r-and-r-colour-editing "mention").
{% endhint %}

![File structure of mlsetup viewed with WolvenKit](https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-f2818013b0e52b02eb70196057e2f54630d1e2ec%2FMLSETUP%20example.png?alt=media\&token=67c5bf3e-8721-4704-a78d-b1790353c944)

## What is the mltemplate?

**MLTEMPLATE** files are the *actual* visible surfaces that appear on meshes using the **multilayered.mt** supershader. The multilayer templates include a wide variety of surfaces such as steel, iron, aluminum, plastic, nylon, linoleum, carpet, soil, grass, rubber, concreate, and everything else imaginable. Each template can use a unique color, normal, roughness, and metallic PBR texture. The mltemplate files are selected from within each layer definition of an **mlsetup** file. Meshes can blend up to 20 mltemplate surfaces into a single material by masking them with the **mlmask**.

![File structure of mltemplate viewed with WolvenKit](https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-53db41224bc253649c9920c19a4869ebd72b6bc2%2FMLTEMPLATE%20example.png?alt=media\&token=640c9a34-8cc1-42a4-b008-c5cdfa34c941)

![A sample preview of some materials created by mltemplate files](https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-dbb4197b22cd026bcb07e07541bcab7e971b3499%2FMLTEMPLATE%20previews.png?alt=media\&token=9f290b5d-ce18-471d-bec5-3c3cd3b8d3f7)

<figure><img src="https://1427525421-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gzcGtLrr90pVjAWVdTc%2Fuploads%2Fgit-blob-d2d7611afe7560387afd639e5d32fa6f875cb81f%2Fmultilayered_properties_roughness.png?alt=media" alt=""><figcaption><p>An example how colour and roughness affect the material in-game</p></figcaption></figure>

## Technical Details

| Multilayered Shaders                                                           |
| ------------------------------------------------------------------------------ |
| engine\materials\multilayered.mt                                               |
| base\materials\multilayered\_clear\_coat.mt \| Adds clearcoat effect           |
| base\materials\vehicle\_destr\_blendshape.mt \| Adds procedural vehicle damage |
| base\materials\cloth\_mov\_multilayered.mt                                     |
| base\materials\multilayered\_terrain.mt                                        |
| base\materials\ver\_mov\_multilayered.mt                                       |

### `multilayered`

<table><thead><tr><th width="192">Texture Channels</th><th width="139" align="center">Red</th><th width="134" align="center">Green</th><th width="146" align="center">Blue</th><th align="center">Alpha</th></tr></thead><tbody><tr><td>GlobalNormal</td><td align="center">Normal R</td><td align="center">Normal G</td><td align="center">?</td><td align="center">?</td></tr><tr><td>MaskAtlas</td><td align="center">?</td><td align="center">?</td><td align="center">?</td><td align="center">?</td></tr></tbody></table>

<table><thead><tr><th width="310">Name</th><th align="center">Description</th></tr></thead><tbody><tr><td>MultilayerMask</td><td align="center">See mlmask</td></tr><tr><td>MultilayerSetup</td><td align="center">See mlsetup</td></tr><tr><td>GlobalNormalIntensity</td><td align="center">Sets visual intensity of normal map texture</td></tr><tr><td>GlobalNormalUVScale</td><td align="center">Sets the scale of the normal map in relation to the uv map (equivalent to tiling)</td></tr><tr><td>GlobalNormalUVBias</td><td align="center">?</td></tr><tr><td>MaskAtlas</td><td align="center">?</td></tr><tr><td>MaskTiles</td><td align="center">?</td></tr><tr><td>Layers</td><td align="center">?</td></tr><tr><td>LayersStartIndex</td><td align="center">?</td></tr><tr><td>SurfaceTexAspectRatio</td><td align="center">Sets number of mlmask layers to be used</td></tr><tr><td>MaskToTileScale</td><td align="center">?</td></tr><tr><td>MaskTileSize</td><td align="center">?</td></tr><tr><td>MaskAtlasDims</td><td align="center">?</td></tr><tr><td>MaskBaseResolution</td><td align="center">?</td></tr><tr><td>SetupLayerMask</td><td align="center">?</td></tr><tr><td>NormalsTextureDDXYMultiplier</td><td align="center">?</td></tr><tr><td>MicroblendsTextureDDXYMultiplier</td><td align="center">?</td></tr></tbody></table>

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.redmodding.org/cyberpunk-2077-modding/for-mod-creators-theory/materials/multilayered.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
