- 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
Lib Utils - Shader API
Allegorithmic utility functions
Tone mapping
These are examples of tone mapping you can use in your shader. Painter doesn't apply any tone mapping except the optional one applied by Yebis. If you decide to do some tone mapping in your shader, it will be applied before Yebis tone mapping.
Perform the S-curve tone mapping based on the parameters sigma and n.
vec3 tonemapSCurve(vec3 value, float sigma, float n) { vec3 pow_value = pow(value, vec3(n)); return pow_value / (pow_value + pow(sigma, n)); }
sRGB conversions
These are the conversions used in Painter. You can override the automatic linear -> sRGB conversion in the viewport by putting this line in your custom shader:
#define DISABLE_FRAMEBUFFER_SRGB_CONVERSION
and doing your own custom conversion.
sRGB to linear color conversion. Scalar version.
float sRGB2linear(float x) { return x <= 0.04045 ? x * 0.0773993808 : // 1.0/12.92 pow((x + 0.055) / 1.055, 2.4); }
sRGB to linear color conversion. RGB version.
vec3 sRGB2linear(vec3 rgb) { return vec3( sRGB2linear(rgb.r), sRGB2linear(rgb.g), sRGB2linear(rgb.b)); }
sRGB to linear color conversion. RGB + Alpha version.
vec4 sRGB2linear(vec4 rgba) { return vec4(sRGB2linear(rgba.rgb), rgba.a); }
Linear to sRGB color conversion. Scalar version.
float linear2sRGB(float x) { return x <= 0.0031308 ? 12.92 * x : 1.055 * pow(x, 0.41666) - 0.055; }
Linear to sRGB color conversion. RGB version.
vec3 linear2sRGB(vec3 rgb) { return vec3( linear2sRGB(rgb.r), linear2sRGB(rgb.g), linear2sRGB(rgb.b)); }
Linear to sRGB color conversion. RGB + Alpha version.
vec4 linear2sRGB(vec4 rgba) { return vec4(linear2sRGB(rgba.rgb), rgba.a); }
Linear to sRGB color conversion optional. Scalar version.
//: param auto conversion_linear_to_srgb uniform bool convert_to_srgb_opt; float linear2sRGBOpt(float x) { return convert_to_srgb_opt ? linear2sRGB(x) : x; }
Linear to sRGB color conversion optional. RGB version.
vec3 linear2sRGBOpt(vec3 rgb) { return convert_to_srgb_opt ? linear2sRGB(rgb) : rgb; }
Linear to sRGB color conversion optional. RGB + Alpha version.
vec4 linear2sRGBOpt(vec4 rgba) { return convert_to_srgb_opt ? linear2sRGB(rgba) : rgba; }
Color conversion. Scalar version.
uniform int output_conversion_method; float convertOutput(float x) { if (output_conversion_method == 0) return x; else if (output_conversion_method == 1) return linear2sRGB(x); else return sRGB2linear(x); }
Color conversion. RGB version.
vec3 convertOutput(vec3 rgb) { if (output_conversion_method == 0) return rgb; else if (output_conversion_method == 1) return linear2sRGB(rgb); else return sRGB2linear(rgb); }
Color conversion. RGB + Alpha version.
vec4 convertOutput(vec4 rgba) { if (output_conversion_method == 0) return rgba; else if (output_conversion_method == 1) return linear2sRGB(rgba); else return sRGB2linear(rgba); }
Dithering
These are some helpers to add dithering to shaders.
Use 8x8 Bayer matrix for dithering mode
import lib-bayer.glsl float getDitherThreshold(uvec2 coords) { return bayerMatrix8(coords); } vec4 RGB2Gray(vec4 rgba) { float gray = 0.299 * rgba.r + 0.587 * rgba.g + 0.114 * rgba.b; return vec4(vec3(gray), rgba.a); }
Remove AO and shadows on glossy metallic surfaces (close to mirrors)
float specularOcclusionCorrection(float diffuseOcclusion, float metallic, float roughness) { return mix(diffuseOcclusion, 1.0, metallic * (1.0 - roughness) * (1.0 - roughness)); }