Custom Shader API

Substance Painter uses shaders to render materials in its realtime viewport. It is possible to write custom shaders to implement new behaviors or to simply make the viewport match other renderers.

Additional shaders for Substance Painter can be found on Substance Share.

The Shader API is also available direclty from the applicaiton, by going into the menu Help > Documentation > Shader API.

Shader reference


Warm up

In Substance Painter, you can write your own shaders in GLSL. We allow you to write only a portion of the fragment shader, which is sometimes called a surface shader. Without further ado, let's introduce the "Hello world" Substance Painter surface shader:

void shade(V2F inputs) {
  diffuseShadingOutput(vec3(1.0, 0.0, 1.0));

Now, if you save this snippet into a .glsl file and load it into Substance Painter by dropping it into your shelf's shader tab, you can now use it and see a beautiful uniform pink color on your mesh.

Surface shader

Engine provided data (or how do I access my channels?)

In Substance Painter, you can access rendering engine parameters (document's channels, additional textures, camera-related data and the like). Here is an exhaustive list of all engine provided parameters :

Engine settings (or how do I specify rendering states?)

In some cases you may want to use a specific rendering configuration (culling, blending, sampling locality, and the like) for an effect. Some rendering states are exposed and can be set in the shader. Here is an exhaustive list of all exposed rendering states :

Custom tweaks (or how do I tweak my shader?)

It's usual to have custom tweaks in a shader. To do so in Substance Painter's shaders, we have introduced a way to specify custom tweaks. Here is an exhaustive list of all custom shader tweaks types :

Embedded libraries

In order to avoid writing a lot of boilerplate code in all of your shaders, we created a small yet practical library of useful functions. Please note that you can't edit it nor create your own at the moment.


You can declare additional non required information to give some hint to the rendering system. Here is the syntax:

//: metadata {
//:   "key1":"value1",
//:   "key2":"value2"
//: }

Supported keys are:

  • custom-ui: Replace the standard shader parameters user interface with a custom view written as a QML module (see scripting documentation). The path can be absolute or relative to one of your shelf custom-ui folder.
  • mdl: define the Iray mdl material to use with the shader. The path syntax is as follow: mdl::folder1::folder2::mdl_filename::material_name where folder1::folder2::mdl_filename is the path inside one of your shelf mdl folder to a mdl file and ::material_name is the name of a material declared inside this mdl file. (ex: "mdl" : "mdl::alg::materials::physically_metallic_roughness::physically_metallic_roughness")

Example shaders (yeah, finally!)

To get a taste of what looks like a real shader, here are a few sample shader, ordered by increasing complexity:

Dynamic material layering

The Dynamic Material Layering is a specific workflow where materials are mixed together inside a shader and let the user dynamically edit blending masks in Substance Painter. To enable this workflow, there are two new functionalities: