User Guide Cancel

PBR Material Layering - Shader API | Substance 3D Painter

  1. Substance 3D home
  2. Home
  3. Getting Started
    1. Getting Started overview
    2. Activation and licenses
    3. System requirements
    4. Project creation
    5. Export
      1. Export overview
      2. Export window
        1. Export window overview
        2. Export settings
        3. Output templates
        4. List of exports
      3. Export presets
        1. Export presets overview
        2. Predefined presets
          1. Predefined Presets
          2. USD PBR Metal Roughness Preset
          3. Default Presets
        3. Creating export presets
    6. Glossary
    7. Performance
  4. Interface
    1. Assets
      1. Assets overview
      2. Navigation
      3. Customizing the layout
      4. Filter by path
      5. Saved searches
      6. Advanced search queries
      7. Adding a new library
      8. Sub-library tab
    2. Substance 3D Assets
    3. Color picker
    4. Display settings
      1. Display settings overview
      2. Environment settings
      3. Camera settings
      4. Viewport settings
    5. History
    6. Layer stack
      1. Layer stack overview
      2. Creating layers
      3. Managing layers
      4. Masking and effects
      5. Blending modes
      6. Layer instancing
      7. Geometry mask
    7. Main menu
      1. Main menu overview
      2. File menu
      3. Edit menu
      4. Mode menu
      5. Window menu
      6. Viewport menu
      7. Plugins menu
      8. Help menu
    8. Project configuration
    9. Properties
    10. Settings
      1. Settings overview
      2. General preferences
      3. Shortcuts
      4. Libraries configuration
    11. Shader settings
      1. Shader settings overview
      2. Updating a shader
    12. Texture Set
      1. Texture Set overview
      2. Texture Set list
      3. Texture Set settings
      4. Texture Set reassignment
    13. Toolbars
    14. Viewport
      1. Viewport overview
      2. 2D view
      3. 3D view
      4. Camera management
    15. Miscellaneous
      1. Sliders
      2. Log
      3. Update checker
  5. Painting
    1. Painting overview
    2. Tool list
      1. Paint brush
      2. Eraser
      3. Projection
      4. Polygon fill
      5. Smudge tool
      6. Clone Tool
      7. Quick mask
      8. Path tool
    3. Straight line   
    4. Lazy mouse 
    5. Symmetry
      1. Symmetry overview
      2. Mirror Symmetry
    6. Fill projections
      1. Fill projections overview
      2. Fill (match per UV Tile)
      3. UV projection
      4. Tri-planar projection
      5. Planar projection
      6. Spherical projection
      7. Cylindrical projection
      8. Warp projection
      9. UV set to UV set projection
    7. Presets
      1. Presets overview
      2. Creating and saving presets
      3. Creating particles presets
        1. Creating particles overview
        2. Installing the particle editor
        3. Overview of the particle editor
        4. Creating a new particle script
      4. Photoshop brush presets (ABR)
        1. Photoshop brush presets overview
        2. Exporting Brush Presets from Photoshop
        3. Importing Photoshop Brush Presets
        4. Photoshop Brush Parameters Compatibility
    8. Dynamic strokes
      1. Dynamic strokes overview
      2. Enabling Dynamic Stroke feature
      3. Dynamic Stroke Performances
      4. Creating custom Dynamic Strokes
    9. Advanced channel painting
      1. Channel painting overview
      2. Ambient Occlusion
      3. Flow Map
      4. Height Map
      5. Normal Map
    10. Vector graphic (.svg & .ai)
    11. Text resource
  6. Effects
    1. Effects overview
    2. Generator
    3. Paint
    4. Fill
    5. Levels
    6. Compare Mask
    7. Filter
    8. Anchor Point
  7. Baking
    1. Baking overview
    2. How to bake mesh maps
    3. Baking visualization settings
  8. Content
    1. Creating custom effects
      1. Creating custom effects overview
      2. Generic filter
      3. Channel specific filter
      4. Generators
      5. Mesh map
      6. Mesh based input
      7. User data
    2. Importing assets
      1. Adding resources via drag and drop
      2. Adding resources via the import window
      3. Adding content on the hard drive
      4. Receiving assets from other Substance 3D applications
  9. Features
    1. Automatic UV Unwrapping
    2. Physical size
    3. Smart Materials and Masks
    4. Subsurface Scattering
      1. Subsurface Scattering overview
      2. Enabling Subsurface in a Project
      3. Subsurface Parameters
      4. Subsurface Material Type
    5. Dynamic Material Layering
    6. UV Reprojection
    7. UV Tiles
      1. UV Tiles overview
      2. Image Sequence
    8. Color Management
      1. Color management overview
      2. Color management with Adobe ACE - ICC
      3. Color management with OpenColorIO
    9. Post Processing
      1. Post Processing overview
      2. Color correction
      3. Depth of Field
      4. Glare
      5. Lens Distortion
      6. Tone Mapping
      7. Vignette
      8. Color Profile
    10. Iray Renderer
      1. Iray Renderer overview
      2. Iray Settings
      3. Viewer and MDL Settings
    11. Plugins
      1. Plugins overview
      2. Autosave
      3. Resources Updater
    12. Sparse Virtual Textures
    13. Custom Shaders
    14. SpaceMouse® by 3Dconnexion
    15. Universal Scene Description (USD)
    16. Send to
  10. Technical Support
    1. Performance Guidelines
      1. Performances guidelines overview
      2. Conflicts and background applications
      3. Mesh and UV setup
      4. GPU Drivers
      5. NVIDIA Drivers Settings
      6. GPU VRAM amount and bandwidth
      7. GPU VRAM and other applications
      8. Texture Sets amount
      9. Layer management
      10. Channels management
      11. Substance filters and materials
      12. Viewport display
    2. Configuring Pens and Tablets
    3. Exporting the log file
    4. Exporting a DXDiag
    5. Technical issues
      1. GPU Issues
        1. Crash when working with overclocked GPU
        2. Forcing the external GPU on Mac OS
        3. GPU drivers compatibility
        4. GPU drivers crash with long computations (TDR crash)
        5. GPU has outdated drivers
        6. GPU is not recognized
        7. GPU is not recognized and is mentionned as GDI Generic
        8. Issues with Nvidia GPUs on recent Mac OS versions
        9. Multi/Bi-GPU
        10. Running on integrated GPU
        11. Painter doesn't start on the right GPU
      2. Startup Issues
        1. Application failed to start because of Qt
        2. Crash or freeze during startup
        3. Software conflicts
      3. Rendering Issues
        1. Artifacts and glitches on Mac OS with Custom GPUs
        2. Blocky artifacts appear on textures in the viewport
        3. Mesh appears pink in the viewport
        4. Mesh flash to white when moving camera
        5. Some HDPI scaling values are not working
      4. Stability Issues
        1. Crash during export
        2. Crash when opening or saving a file
        3. Crash while baking
        4. Crash with low virtual memory
        5. Windows Blue Screens
      5. Miscellaneous Issues
        1. Corrupted texture error message
        2. Shelf resources are gone after 7.2 update
        3. Error there is no disk in the drive
        4. Error with missing api-ms-crt dll
        5. Impossible to drag and drop files into the shelf
        6. Impossible to use the ALT keyboard shortcut on Linux
        7. Assets (or shelf) previews are empty
    6. Workflow Issues
      1. Export Issues
        1. My exported opacity map is totally black
        2. Texture dilation or Padding
      2. Tools Issues
        1. Normal map looks incorrect when loaded in layer or tool properties
        2. Paint Tool bleeds on other UV islands
      3. Project Issues
        1. A project has been processed as a text file and is now corrupted
        2. Loading files from a network
        3. Preserve brush strokes setting stays disabled
        4. Projects are really big
      4. Library Issues
        1. Thumbnails in the shelf look incorrect
        2. Error when importing a Font
      5. Viewport Issues
        1. Mesh faces disappear when looking at them from behind
        2. Viewports and textures are blurry or lack sharpness
      6. Plugins Issues
        1. Substance Source plugin doesn't load
      7. License Issues
        1. Maintenance is expired dialog on startup
  11. Pipeline and integration
    1. Installation and preferences
      1. Preferences and application data location
      2. Automated installation
      3. Retrieving the installation path
    2. Configuration
      1. Command lines
      2. Environment variables
      3. Firewall Configuration
      4. Querying Current Software Version
      5. Remote Desktop
    3. Resource management
      1. Shelf and Assets location
      2. Resource paths
        1. Adding resource paths by editing preferences manually
        2. Editing resource paths manually
        3. Editing the Shelf Preferences with Python
      3. Adding saved searches manually
      4. Preferences and content migration
      5. Excluding resources in a resource path
  12. Scripting and development
    1. Scripts and plugins
      1. Creating a Javascript plugin
      2. Remote control with scripting
    2. Shader API Reference
      1. Shader API overview
      2. Changelog - Shader API
      3. Libraries - Shader API
        1. Lib Alpha - Shader API
        2. Lib Bayer - Shader API
        3. Lib Defines - Shader API
        4. Lib Emissive - Shader API
        5. Lib Env - Shader API
        6. Lib Normal - Shader API
        7. Lib PBR - Shader API
        8. Lib PBR Aniso - Shader API
        9. Lib Pom - Shader API
        10. Lib Random - Shader API
        11. Lib Sampler - Shader API
        12. Lib Sparse - Shader API
        13. Lib SSS - Shader API
        14. Lib Utils - Shader API
        15. Lib Vectors - Shader API
      4. Parameters - Shader API
        1. All Custom Params - Shader API
        2. All Engine Params - Shader API
        3. All Rendering States Params - Shader API
        4. Layering Bind Materials - Shader API
        5. Layering Declare Stacks - Shader API
      5. Shaders - Shader API
        1. PBR Material Layering - Shader API
        2. PBR Metal Rough - Shader API
        3. Pixelated - Shader API
        4. Surface Shader - Shader API
        5. Toon - Shader API
  13. Release notes
    1. Release notes overview
    2. All Changes
    3. Version 10.1
    4. Version 10.0
    5. Version 9.1
    6. Old versions
      1. Version 9.0
      2. Version 8.3
      3. Version 8.2
      4. Version 8.1
      5. Version 7.4
      6. Version 7.3
      7. Version 7.2
      8. Version 2021.1 (7.1.0)
      9. Version 2020.2 (6.2.0)
      10. Version 2020.1 (6.1.0)
      11. Version 2019.3
      12. Version 2019.2
      13. Version 2019.1
      14. Version 2018.3
      15. Version 2018.2
      16. Version 2018.1
      17. Version 2017.4
      18. Version 2017.3
      19. Version 2017.2
      20. Version 2017.1
      21. Version 2.6
      22. Version 2.5
      23. Version 2.4
      24. Version 2.3
      25. Version 2.2

PBR Material Layering - Shader API

Import from libraries.

import lib-pbr.glsl 
import lib-emissive.glsl 
import lib-sampler.glsl 
import lib-utils.glsl 
 
#define NB_MATERIALS 4 
#define NB_MASKS     (NB_MATERIALS - 1) 
 
//: metadata { 
//:   "custom-ui": "material-layering/custom-ui.qml" 
//: } 
 
//: materials [ 
//:   { 
//:      "id": "Material1", 
//:      "label": "Material 1", 
//:      "default": "", 
//:      "size": 1024, 
//:      "default_color": [0.5, 0.5, 0.5] 
//:   }, 
//:   { 
//:      "id": "Material2", 
//:      "label": "Material 2", 
//:      "default": "", 
//:      "size": 1024, 
//:      "default_color": [0.5, 0.5, 0.5] 
//:   }, 
//:   { 
//:      "id": "Material3", 
//:      "label": "Material 3", 
//:      "default": "", 
//:      "size": 1024, 
//:      "default_color": [0.5, 0.5, 0.5] 
//:   }, 
//:   { 
//:      "id": "Material4", 
//:      "label": "Material 4", 
//:      "default": "", 
//:      "size": 1024, 
//:      "default_color": [0.5, 0.5, 0.5] 
//:   } 
//: ] 
 
 
//: stacks [ 
//:   { 
//:     "id": "Mask", 
//:     "channels": 
//:  [ 
//:   {"id": "blendingmask"} 
//:  ] 
//:   }, 
//:   { 
//:     "id": "Mask2", 
//:     "channels": 
//:  [ 
//:   {"id": "blendingmask"} 
//:  ] 
//:   }, 
//:   { 
//:     "id": "Mask3", 
//:     "channels": 
//:  [ 
//:   {"id": "blendingmask"} 
//:  ] 
//:   } 
//: ] 
 
 
 
//: param custom { "default": false, "label": "Debug Mode" } 
uniform bool DebugMode; 
 
//: param custom { 
//:   "default": 0, 
//:   "label": "Debug channel", 
//:   "widget": "combobox", 
//:   "values": { 
//:     "BaseColor": 0, 
//:     "Roughness": 1, 
//:     "Metallic": 2, 
//:     "Normal (Material)": 3, 
//:     "Normal (Masks)": 4, 
//:     "Normal (Combined)": 5, 
//:     "Mask 1": 6, 
//:     "Mask 2": 7, 
//:     "Mask 3": 8 
//:   } 
//: } 
uniform int DebugChannel; 
 
 
//: param custom { "default": false, "label": "Normal from Masks" } 
uniform bool UseNormalFromMask;

Channels needed for metal/rough workflow are bound here.

//: param auto texture_normal; 
uniform sampler2D mesh_normal_texture; 
 
//: param custom { "default": 5, "label": "Material 1 coords", "min": 0.01, "max": 128.0, "group" : "Material 1" } 
uniform float u_coords1; 
 
//: param custom { "default": 5, "label": "Material 2 coords", "min": 0.01, "max": 128.0, "group" : "Material 2" } 
uniform float u_coords2; 
 
//: param custom { "default": 5, "label": "Material 3 coords", "min": 0.01, "max": 128.0, "group" : "Material 3" } 
uniform float u_coords3; 
 
//: param custom { "default": 5, "label": "Material 4 coords", "min": 0.01, "max": 128.0, "group" : "Material 4" } 
uniform float u_coords4; 
 
 
//: param custom { "default": 1, "label": "Normal Intensity 1", "min": 0.0, "max": 1.0, "group" : "Material 1" } 
uniform float normal_intensity1; 
 
//: param custom { "default": 1, "label": "Normal Intensity 2", "min": 0.0, "max": 1.0, "group" : "Material 2" } 
uniform float normal_intensity2; 
 
//: param custom { "default": 1, "label": "Normal Intensity 3", "min": 0.0, "max": 1.0, "group" : "Material 3" } 
uniform float normal_intensity3; 
 
//: param custom { "default": 1, "label": "Normal Intensity 4", "min": 0.0, "max": 1.0, "group" : "Material 4" } 
uniform float normal_intensity4; 
 
 
//: param custom { "default": 0, "label": "Normal from Mask Intensity 2", "min": -10.0, "max": 10.0, "group" : "Material 2" } 
uniform float mask_normal_intensity1; 
 
//: param custom { "default": 0, "label": "Normal from Mask Intensity 3", "min": -10.0, "max": 10.0, "group" : "Material 3" } 
uniform float mask_normal_intensity2; 
 
//: param custom { "default": 0, "label": "Normal from Mask Intensity 4", "min": -10.0, "max": 10.0, "group" : "Material 4" } 
uniform float mask_normal_intensity3; 
 
 
//: param custom { "default": 0.1, "label": "Normal from Mask 1 Offset", "min": 0.0, "max": 1, "group" : "Material 2" } 
uniform float mask_normal_offset1; 
 
//: param custom { "default": 0.1, "label": "Normal from Mask 2 Offset", "min": 0.0, "max": 1, "group" : "Material 3" } 
uniform float mask_normal_offset2; 
 
//: param custom { "default": 0.1, "label": "Normal from Mask 3 Offset", "min": 0.0, "max": 1, "group" : "Material 4" } 
uniform float mask_normal_offset3; 
 
 
//: param auto Material1.channel_basecolor 
uniform sampler2D color1; 
 
//: param auto Material1.channel_roughness 
uniform sampler2D rough1; 
 
//: param auto Material1.channel_metallic 
uniform sampler2D metal1; 
 
//: param auto Material1.channel_normal 
uniform sampler2D normal1; 
 
 
//: param auto Material2.channel_basecolor 
uniform sampler2D color2; 
 
//: param auto Material2.channel_roughness 
uniform sampler2D rough2; 
 
//: param auto Material2.channel_metallic 
uniform sampler2D metal2; 
 
//: param auto Material2.channel_normal 
uniform sampler2D normal2; 
 
 
//: param auto Material3.channel_basecolor 
uniform sampler2D color3; 
 
//: param auto Material3.channel_roughness 
uniform sampler2D rough3; 
 
//: param auto Material3.channel_metallic 
uniform sampler2D metal3; 
 
//: param auto Material3.channel_normal 
uniform sampler2D normal3; 
 
 
//: param auto Material4.channel_basecolor 
uniform sampler2D color4; 
 
//: param auto Material4.channel_roughness 
uniform sampler2D rough4; 
 
//: param auto Material4.channel_metallic 
uniform sampler2D metal4; 
 
//: param auto Material4.channel_normal 
uniform sampler2D normal4; 
 
 
//: param auto Mask.channel_blendingmask 
uniform SamplerSparse mask; 
 
//: param auto Mask2.channel_blendingmask 
uniform SamplerSparse mask2; 
 
//: param auto Mask3.channel_blendingmask 
uniform SamplerSparse mask3; 
 
///////////////////////////////////////// 
////////// BLENDING FUNCTIONS /////////// 
///////////////////////////////////////// 
 
float mixGrayscale( 
 float channelSampled[NB_MATERIALS], 
 float Masks[NB_MASKS]) 
{ 
 float result = channelSampled[0]; 
 for (int i = 0; i < NB_MASKS; i++) 
  result = mix(result, channelSampled[i + 1], Masks[i]); 
 
 return result; 
} 
 
vec3 mixColor( 
 vec3 channelSampled[NB_MATERIALS], 
 float Masks[NB_MASKS]) 
{ 
 vec3 result = channelSampled[0]; 
 for (int i = 0; i < NB_MASKS; i++) 
  result = mix(result, channelSampled[i + 1], Masks[i]); 
 
 return result; 
} 
 
vec3 mixNormal( 
 vec3 channelSampled[NB_MATERIALS], 
 float Masks[NB_MASKS], 
 float NormalIntensity[NB_MATERIALS]) 
{ 
 vec3 result = NormalIntensity[0] * channelSampled[0]; 
 for (int i = 0; i < NB_MASKS; i++) 
  result = mix(result, NormalIntensity[i + 1] * channelSampled[i + 1], Masks[i]); 
 
 return result; 
} 
 
vec3 NormalFromMask(SamplerSparse Mask, float Offset, float Intensity, SparseCoord UVs, float refMask) 
{ 
 vec4 results[2]; 
 vec2 offsets[2] = vec2[2]( 
  vec2(Offset * 0.001, 0.0), 
  vec2(0.0, Offset * 0.001) 
 ); 
 textureSparseOffsets(Mask, UVs, offsets, results); 
 
 float Channel1 = results[0].r - refMask; 
 float Channel2 = results[1].r - refMask; 
 
 return vec3(-Intensity * Channel1, -Intensity * Channel2, 1.0); 
} 
 
vec3 NormalFromMasks( 
 vec3 normalFromMaskSampled[NB_MASKS], 
 float Masks[NB_MASKS]) 
{ 
 vec3 result = normalFromMaskSampled[0]; 
 for (int i = 1; i < NB_MASKS; i++) 
  result = mix(result, normalFromMaskSampled[i], Masks[i]); 
 
 return result; 
} 
 
 
void shade(V2F inputs) 
{

 //Global textures

 // Get detail (ambient occlusion) and global (shadow) occlusion factors 
 float occlusion = getAO(inputs.sparse_coord) * getShadowFactor(); 
 vec3 mesh_normal = normalUnpack(textureSparse(base_normal_texture, inputs.sparse_coord), base_normal_y_coeff);

 //Materials Masks

 float UVscale[NB_MATERIALS] = float[NB_MATERIALS]( 
  u_coords1, u_coords2, u_coords3, u_coords4); 
 
 float NormalIntensity[NB_MATERIALS] = float[NB_MATERIALS]( 
  normal_intensity1, normal_intensity2, normal_intensity3, normal_intensity4); 
 
 float MaskNormalOffset[NB_MASKS] = float[NB_MASKS]( 
  mask_normal_offset1, mask_normal_offset2, mask_normal_offset3); 
 
 float MaskNormalIntensity[NB_MASKS] = float[NB_MASKS]( 
  mask_normal_intensity1, mask_normal_intensity2, mask_normal_intensity3); 
 
 float Masks[NB_MASKS] = float[NB_MASKS]( 
  textureSparse(mask , inputs.sparse_coord).r, 
  textureSparse(mask2, inputs.sparse_coord).r, 
  textureSparse(mask3, inputs.sparse_coord).r); 
 
 float roughSampled[NB_MATERIALS] = float[NB_MATERIALS]( 
  getRoughness(rough1, inputs.tex_coord*UVscale[0]), 
  getRoughness(rough2, inputs.tex_coord*UVscale[1]), 
  getRoughness(rough3, inputs.tex_coord*UVscale[2]), 
  getRoughness(rough4, inputs.tex_coord*UVscale[3]) 
 ); 
 
 float metallicSampled[NB_MATERIALS] = float[NB_MATERIALS]( 
  getMetallic(metal1, inputs.tex_coord*UVscale[0]), 
  getMetallic(metal2, inputs.tex_coord*UVscale[1]), 
  getMetallic(metal3, inputs.tex_coord*UVscale[2]), 
  getMetallic(metal4, inputs.tex_coord*UVscale[3]) 
 ); 
 
 vec3 basecolorSampled[NB_MATERIALS] = vec3[NB_MATERIALS]( 
  getBaseColor(color1, inputs.tex_coord*UVscale[0]), 
  getBaseColor(color2, inputs.tex_coord*UVscale[1]), 
  getBaseColor(color3, inputs.tex_coord*UVscale[2]), 
  getBaseColor(color4, inputs.tex_coord*UVscale[3]) 
 ); 
 
 vec3 normalSampled[NB_MATERIALS] = vec3[NB_MATERIALS]( 
  normalUnpack(texture(normal1, inputs.tex_coord*UVscale[0])), 
  normalUnpack(texture(normal2, inputs.tex_coord*UVscale[1])), 
  normalUnpack(texture(normal3, inputs.tex_coord*UVscale[2])), 
  normalUnpack(texture(normal4, inputs.tex_coord*UVscale[3])) 
 );

 //Mixing

 float roughness = mixGrayscale(roughSampled, Masks); 
 float metallic = mixGrayscale(metallicSampled, Masks); 
 vec3 basecolor = mixColor(basecolorSampled, Masks); 
 vec3 diffColor = generateDiffuseColor(basecolor, metallic); 
 vec3 specColor = generateSpecularColor(basecolor, metallic); 
 float specOcclusion = specularOcclusionCorrection(occlusion, metallic, roughness); 
 
 //Normal channel 
 vec3 normal = mixNormal(normalSampled, Masks, NormalIntensity); 
 normal = normalize( vec3(normal.xy + mesh_normal.xy, mesh_normal.z) ); //UDN combine method 
 
 vec3 finalNormal = normal; 
 vec3 normalMask = vec3(0.0, 0.0, 1.0); 
 
 if( UseNormalFromMask ) 
 { 
  vec3 normalFromMaskSampled[NB_MASKS] = vec3[NB_MASKS]( 
   NormalFromMask(mask , MaskNormalOffset[0], MaskNormalIntensity[0], inputs.sparse_coord, Masks[0]), 
   NormalFromMask(mask2, MaskNormalOffset[1], MaskNormalIntensity[1], inputs.sparse_coord, Masks[1]), 
   NormalFromMask(mask3, MaskNormalOffset[2], MaskNormalIntensity[2], inputs.sparse_coord, Masks[2]) 
  ); 
 
  normalMask = NormalFromMasks(normalFromMaskSampled, Masks); 
  finalNormal = normalize( vec3(finalNormal.xy + normalMask.xy, finalNormal.z) ); //UDN combine method 
 }

 //Final

 //Debug mode display result of combined channels or Masks 
 if( !DebugMode ) { 
  vec3 finalNormalWorldSpace = normalize( 
   finalNormal.x * inputs.tangent + 
   finalNormal.y * inputs.bitangent + 
   finalNormal.z * inputs.normal); 
  // Feed parameters for a physically based BRDF integration. 
  LocalVectors vectors = computeLocalFrame(inputs, finalNormalWorldSpace, 0.0); 
  emissiveColorOutput(pbrComputeEmissive(emissive_tex, inputs.sparse_coord)); 
  diffuseShadingOutput(occlusion * pbrComputeDiffuse(vectors.normal, diffColor)); 
  specularShadingOutput(specOcclusion * pbrComputeSpecular(vectors, specColor, roughness)); 
 } else { 
  vec3 result; 
 
  //BaseColor combined 
  if( DebugChannel == 0 ) { 
   result = basecolor; 
  } 
 
  //Roughness combined 
  else if( DebugChannel == 1 ) { 
   result = vec3(roughness); 
  } 
 
  //Metallic combined 
  else if( DebugChannel == 2 ) { 
   result = vec3(metallic); 
  } 
 
  //Normal combined 
  else if( DebugChannel == 3) { 
   normal = 0.5 * normal + vec3(0.5); 
   result = sRGB2linear(normal); 
  } 
 
  //Combined masks as Normal 
  else if( DebugChannel == 4 ) { 
   normalMask = 0.5 * normalMask + vec3(0.5); 
   result = sRGB2linear(normalMask); 
  } 
 
  //Final Normal 
  else if( DebugChannel == 5 ) { 
   finalNormal = 0.5 * finalNormal + vec3(0.5); 
   result = sRGB2linear(finalNormal); 
  } 
 
  //Mask(s) 
  else { 
   result = vec3(sRGB2linear(Masks[DebugChannel - 6])); 
  } 
 
  diffuseShadingOutput(result); 
 } 
} 
 

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online