Edit in GitHubLog an issue

Shader reference


Changelog

Warm up

In Substance 3D 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 3D Painter surface shader:

Copied to your clipboard
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 3D 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

In Substance 3D 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

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

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

Custom qualifiers

Beside regular GLSL qualifiers, we added a custom uniform_specialization qualifier that can be used as drop-in replacement of uniform to optimize uber shaders :

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.

Metadata

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

Copied to your clipboard
//: 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::painter::pbr::physically_metallic_roughness")

Example shaders

To better understand how to write a complete shader, here are a few examples, 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 3D Painter. To enable this workflow, there are two new functionalities:

Next steps

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.