Documentation for Substance 3D Painter is now available on Experience League. After March 14th, HelpX pages will automatically redirect to the equivalent Experience League page.
Refer to the FAQ for more information about which documentation is affected.
Last updated on
Jul 13, 2023
- Substance 3D home
- Home
- Getting Started
- Getting Started overview
- Activation and licenses
- System requirements
- Project creation
- Export
- Export overview
- Export window
- Output templates
- Export overview
- Glossary
- Getting Started overview
- Interface
- Interface overview
- Assets
- Substance 3D Assets
- Color picker
- Display settings
- History
- Layer stack
- Main menu
- Project configuration
- Properties
- Settings
- Shader settings
- Texture Set
- Toolbars
- Viewport
- Miscellaneous
- Painting
- Painting overview
- Paint tools
- Path tools
- Path tool overview
- Paint along path
- Ribbon path
- Filled path
- Erase along path
- Smudge along path
- Straight line
- Lazy mouse
- Symmetry
- Fill projections
- Presets
- Presets overview
- Creating and saving presets
- Creating particles presets
- Photoshop brush presets
- Dynamic strokes
- Advanced channel painting
- Vector graphic (.svg & .ai)
- Text resource
- Effects
- Baking
- Content
- Creating custom effects
- Importing assets
- Creating custom effects
- Features
- Automatic resource update
- 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 11.1
- Version 11.0
- Version 10.1
- Known issues
- Old versions
- Version 10.0
- Version 9.1
- 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 Vectors - Shader API
lib-vectors.glsl
Public Functions: computeLocalFrame getEyeVec tangentSpaceToWorldSpace worldSpaceToTangentSpace
Import from library
import lib-normal.glsl
Which view is shaded.
//: param auto is_2d_view uniform bool is2DView;
What kind of projection is used.
//: param auto is_perspective_projection uniform bool is_perspective;
Eye position in world space.
//: param auto world_eye_position uniform vec3 camera_pos;
Camera orientation in world space.
//: param auto world_camera_direction
uniform vec3 camera_dir;
//: param auto facing
uniform int facing;
bool isBackFace() {
return facing == -1 || (facing == 0 && !gl_FrontFacing);
}
Compute the world space eye vector
vec3 getEyeVec(vec3 position) {
return is_perspective ?
normalize(camera_pos - position) :
-camera_dir;
}
Convert a vector from tangent space to world space
vec3 tangentSpaceToWorldSpace(vec3 vecTS, V2F inputs) {
return normalize(
vecTS.x * inputs.tangent +
vecTS.y * inputs.bitangent +
vecTS.z * inputs.normal);
}
Convert a vector from world space to tangent space
vec3 worldSpaceToTangentSpace(vec3 vecWS, V2F inputs) {
// Assume the transformation is orthogonal
return normalize(vecWS * mat3(inputs.tangent, inputs.bitangent, inputs.normal));
}
Local frame of vertex in world space
struct LocalVectors {
vec3 vertexNormal;
vec3 tangent, bitangent, normal, eye;
};
Compute local frame from custom world space normal and anisotropy angle
LocalVectors computeLocalFrame(V2F inputs, vec3 normal, float anisoAngle) {
LocalVectors vectors;
vectors.vertexNormal = inputs.normal;
vectors.normal = normal;
// Flip the normals for back facing polygons
if (isBackFace()) {
vectors.vertexNormal = -vectors.vertexNormal;
vectors.normal = -vectors.normal;
}
vectors.eye = is2DView ?
vectors.normal : // In 2D view, put view vector along the normal
getEyeVec(inputs.position);
// Trick to remove black artifacts
// Backface ? place the eye at the opposite - removes black zones
if (dot(vectors.eye, vectors.normal) < 0.0) {
vectors.eye = reflect(vectors.eye, vectors.normal);
}
// Create a local frame for BRDF work
vec3 tangent = normalize(
inputs.tangent
- vectors.normal * dot(inputs.tangent, vectors.normal)
);
vec3 bitangent = normalize(
inputs.bitangent
- vectors.normal * dot(inputs.bitangent, vectors.normal)
- tangent * dot(inputs.bitangent, tangent)
);
float cosAngle = cos(anisoAngle);
float sinAngle = sin(anisoAngle);
vectors.tangent = cosAngle * tangent - sinAngle * bitangent;
vectors.bitangent = cosAngle * bitangent + sinAngle * tangent;
return vectors;
}
Compute local frame from mesh and document height and normals
LocalVectors computeLocalFrame(V2F inputs) {
// Get world space normal
vec3 normal = computeWSNormal(inputs.sparse_coord, inputs.tangent, inputs.bitangent, inputs.normal);
return computeLocalFrame(inputs, normal, 0.0);
}