#

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:

vec3 shade(V2F inputs) {
  return 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.

But you wonder, what's this V2F type there. Here is its definition:

struct V2F {
  vec3 normal;     // interpolated normal
  vec3 tangent;    // interpolated tangent
  vec3 bitangent;  // interpolated bitangent
  vec3 position;   // interpolated position
  vec2 tex_coord;  // interpolated texture coordinates (uv0)
};
#

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, 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.

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: