Last updated on
Jul 13, 2023
- Getting Started overview
- Activation and licenses
- System requirements
- Project creation
-
Export
- Export overview
- Export window
- Export presets
- Glossary
- Performance
- 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 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
- Creating custom effects
- Importing assets
- 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
- 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
- Installation and preferences
- Configuration
- Resource management
- Scripts and plugins
- 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
- Substance 3D home
- Home
-
Getting Started
- Getting Started overview
- Activation and licenses
- System requirements
- Project creation
-
Export
- Export overview
- Export window
- Export presets
- Glossary
- Performance
-
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
-
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
-
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
-
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 Env - Shader API
lib-env.glsl
Public Functions: envSampleLOD envIrradiance
Needed for math constants
import lib-defines.glsl
import lib-defines.glsl
import lib-defines.glsl
Engine provided parameters
//: param auto texture_environment
uniform sampler2D environment_texture;
//: param auto environment_rotation
uniform float environment_rotation;
//: param auto environment_exposure
uniform float environment_exposure;
//: param auto environment_irrad_mat_red
uniform mat4 irrad_mat_red;
//: param auto environment_irrad_mat_green
uniform mat4 irrad_mat_green;
//: param auto environment_irrad_mat_blue
uniform mat4 irrad_mat_blue;
//: param auto texture_environment
uniform sampler2D environment_texture;
//: param auto environment_rotation
uniform float environment_rotation;
//: param auto environment_exposure
uniform float environment_exposure;
//: param auto environment_irrad_mat_red
uniform mat4 irrad_mat_red;
//: param auto environment_irrad_mat_green
uniform mat4 irrad_mat_green;
//: param auto environment_irrad_mat_blue
uniform mat4 irrad_mat_blue;
//: param auto texture_environment uniform sampler2D environment_texture; //: param auto environment_rotation uniform float environment_rotation; //: param auto environment_exposure uniform float environment_exposure; //: param auto environment_irrad_mat_red uniform mat4 irrad_mat_red; //: param auto environment_irrad_mat_green uniform mat4 irrad_mat_green; //: param auto environment_irrad_mat_blue uniform mat4 irrad_mat_blue;
Helper that allows one to sample environment. Rotation is taken into account. The environment map is a panoramic env map behind the scene, that's why there is extra computation from dir vector.
vec3 envSampleLOD(vec3 dir, float lod)
{
// WORKAROUND: Intel GLSL compiler for HD5000 is bugged on OSX:
// https://bugs.chromium.org/p/chromium/issues/detail?id=308366
// It is necessary to replace atan(y, -x) by atan(y, -1.0 * x) to force
// the second parameter to be interpreted as a float
vec2 pos = M_INV_PI * vec2(atan(-dir.z, -1.0 * dir.x), 2.0 * asin(dir.y));
pos = 0.5 * pos + vec2(0.5);
pos.x += environment_rotation;
return textureLod(environment_texture, pos, lod).rgb * environment_exposure;
}
vec3 envSampleLOD(vec3 dir, float lod)
{
// WORKAROUND: Intel GLSL compiler for HD5000 is bugged on OSX:
// https://bugs.chromium.org/p/chromium/issues/detail?id=308366
// It is necessary to replace atan(y, -x) by atan(y, -1.0 * x) to force
// the second parameter to be interpreted as a float
vec2 pos = M_INV_PI * vec2(atan(-dir.z, -1.0 * dir.x), 2.0 * asin(dir.y));
pos = 0.5 * pos + vec2(0.5);
pos.x += environment_rotation;
return textureLod(environment_texture, pos, lod).rgb * environment_exposure;
}
vec3 envSampleLOD(vec3 dir, float lod) { // WORKAROUND: Intel GLSL compiler for HD5000 is bugged on OSX: // https://bugs.chromium.org/p/chromium/issues/detail?id=308366 // It is necessary to replace atan(y, -x) by atan(y, -1.0 * x) to force // the second parameter to be interpreted as a float vec2 pos = M_INV_PI * vec2(atan(-dir.z, -1.0 * dir.x), 2.0 * asin(dir.y)); pos = 0.5 * pos + vec2(0.5); pos.x += environment_rotation; return textureLod(environment_texture, pos, lod).rgb * environment_exposure; }
Return the irradiance for a given direction. The computation is based on environment's spherical harmonics projection.
vec3 envIrradiance(vec3 dir)
{
float rot = environment_rotation * M_2PI;
float crot = cos(rot);
float srot = sin(rot);
vec4 shDir = vec4(dir.xzy, 1.0);
shDir = vec4(
shDir.x * crot - shDir.y * srot,
shDir.x * srot + shDir.y * crot,
shDir.z,
1.0);
return max(vec3(0.0), vec3(
dot(shDir, irrad_mat_red * shDir),
dot(shDir, irrad_mat_green * shDir),
dot(shDir, irrad_mat_blue * shDir)
)) * environment_exposure;
}
vec3 envIrradiance(vec3 dir)
{
float rot = environment_rotation * M_2PI;
float crot = cos(rot);
float srot = sin(rot);
vec4 shDir = vec4(dir.xzy, 1.0);
shDir = vec4(
shDir.x * crot - shDir.y * srot,
shDir.x * srot + shDir.y * crot,
shDir.z,
1.0);
return max(vec3(0.0), vec3(
dot(shDir, irrad_mat_red * shDir),
dot(shDir, irrad_mat_green * shDir),
dot(shDir, irrad_mat_blue * shDir)
)) * environment_exposure;
}
vec3 envIrradiance(vec3 dir) { float rot = environment_rotation * M_2PI; float crot = cos(rot); float srot = sin(rot); vec4 shDir = vec4(dir.xzy, 1.0); shDir = vec4( shDir.x * crot - shDir.y * srot, shDir.x * srot + shDir.y * crot, shDir.z, 1.0); return max(vec3(0.0), vec3( dot(shDir, irrad_mat_red * shDir), dot(shDir, irrad_mat_green * shDir), dot(shDir, irrad_mat_blue * shDir) )) * environment_exposure; }