- Substance 3D home
- Home
- Getting Started
- Getting Started overview
- Activation and licenses
- System requirements
- Project creation
- Export
- Export overview
- Export window
- Export presets
- Export overview
- Glossary
- Performance
- Getting Started overview
- Interface
- Assets
- Substance 3D Assets
- Color picker
- Display settings
- History
- Layer stack
- Main menu
- Project configuration
- Properties
- Settings
- Shader settings
- Texture Set
- Toolbars
- Viewport
- Miscellaneous
- Assets
- Painting
- Painting overview
- Tool list
- Straight line
- Lazy mouse
- Symmetry
- Fill projections
- Presets
- Presets overview
- Creating and saving presets
- Creating particles presets
- Photoshop brush presets (ABR)
- Dynamic strokes
- Advanced channel painting
- Vector graphic (.svg & .ai)
- Text resource
- Effects
- Baking
- Content
- Creating custom effects
- Importing assets
- Creating custom effects
- Features
- Automatic UV Unwrapping
- Physical size
- Smart Materials and Masks
- Subsurface Scattering
- Dynamic Material Layering
- UV Reprojection
- UV Tiles
- Color Management
- Post Processing
- Iray Renderer
- Plugins
- Sparse Virtual Textures
- Custom Shaders
- SpaceMouse® by 3Dconnexion
- Universal Scene Description (USD)
- Send to
- Technical Support
- Performance Guidelines
- Configuring Pens and Tablets
- Exporting the log file
- Exporting a DXDiag
- Technical issues
- GPU Issues
- Crash when working with overclocked GPU
- Forcing the external GPU on Mac OS
- GPU drivers compatibility
- GPU drivers crash with long computations (TDR crash)
- GPU has outdated drivers
- GPU is not recognized
- GPU is not recognized and is mentionned as GDI Generic
- Issues with Nvidia GPUs on recent Mac OS versions
- Multi/Bi-GPU
- Running on integrated GPU
- Painter doesn't start on the right GPU
- Startup Issues
- Rendering Issues
- Stability Issues
- Miscellaneous Issues
- GPU Issues
- Workflow Issues
- Export Issues
- Tools Issues
- Project Issues
- Library Issues
- Viewport Issues
- Plugins Issues
- License Issues
- Pipeline and integration
- Installation and preferences
- Configuration
- Resource management
- Scripting and development
- Scripts and plugins
- Shader API Reference
- Shader API overview
- Changelog - Shader API
- Libraries - Shader API
- Lib Alpha - Shader API
- Lib Bayer - Shader API
- Lib Defines - Shader API
- Lib Emissive - Shader API
- Lib Env - Shader API
- Lib Normal - Shader API
- Lib PBR - Shader API
- Lib PBR Aniso - Shader API
- Lib Pom - Shader API
- Lib Random - Shader API
- Lib Sampler - Shader API
- Lib Sparse - Shader API
- Lib SSS - Shader API
- Lib Utils - Shader API
- Lib Vectors - Shader API
- Parameters - Shader API
- Shaders - Shader API
- Release notes
- Release notes overview
- All Changes
- Version 10.1
- Version 10.0
- Version 9.1
- Old versions
- Version 9.0
- Version 8.3
- Version 8.2
- Version 8.1
- Version 7.4
- Version 7.3
- Version 7.2
- Version 2021.1 (7.1.0)
- Version 2020.2 (6.2.0)
- Version 2020.1 (6.1.0)
- Version 2019.3
- Version 2019.2
- Version 2019.1
- Version 2018.3
- Version 2018.2
- Version 2018.1
- Version 2017.4
- Version 2017.3
- Version 2017.2
- Version 2017.1
- Version 2.6
- Version 2.5
- Version 2.4
- Version 2.3
- Version 2.2
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 directly from the application, by going into the menu Help > Documentation > Shader API.
Shader reference
Changelog
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.
- lib-alpha.glsl : contains opacity related helpers
- lib-bayer.glsl : contains bayer matrix helpers
- lib-defines.glsl : contains useful math constants
- lib-emissive.glsl : contains emissive properties helpers
- lib-env.glsl : contains environment map related helpers
- lib-normal.glsl : contains normal map related helpers (and height-map generated normal map)
- lib-pbr.glsl : contains physically based rendering helpers
- lib-pbr-aniso.glsl : contains anisotropic physically based rendering helpers
- lib-pom.glsl : contains parallax occlusion mapping helpers
- lib-random.glsl : contains random utilities (low discrepancy sequences)
- lib-sampler.glsl : contains channel getters helpers
- lib-sparse.glsl : contains safe sparse texture sampling helpers
- lib-sss.glsl : contains subsurface scattering helpers
- lib-utils.glsl : contains color utility functions (sRGB conversions, tone mapping)
- lib-vectors.glsl : contains common vectors helpers
Metadata
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:
- pixelated.glsl : a pixelating shader
- toon.glsl : a toon shader
- pbr-metal-rough.glsl : the default PBR shader embedded in Substance Painter
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:
- declare editable stacks from a shader definition: layering_declare_stacks.glsl
- bind materials as shader parameters: layering_bind_materials.glsl