- 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
Pixelated - Shader API
Basic pixelating shader
Import from libraries.
import lib-sampler.glsl
We define the global light position
const vec3 light_pos = vec3(10.0, 10.0, 10.0);
We bind the auto param world eye position to our uniform camera_pos.
//: param auto world_eye_position uniform vec3 camera_pos;
We bind the document's channel base color to our uniform basecolor_tex.
//: param auto channel_basecolor uniform SamplerSparse basecolor_tex;
We define a new custom tweak for this shader, along with its default value. This one is used to tweak the thickness of outline, when shadowed.
//: param custom { //: "default": 0.4, //: "min": 0.0, //: "max": 1.0, //: "label": "Unlit outline thickness" //: } uniform float unlit_outline_thickness;
We define a new custom tweak for this shader, along with its default value. This one is used to tweak the thickness of outline, when lit.
//: param custom { //: "default": 0.1, //: "min": 0.0, //: "max": 1.0, //: "label": "Lit outline thickness" //: } uniform float lit_outline_thickness;
Entry point of the shader.
void shade(V2F inputs) {
We compute a few useful values.
vec3 V = normalize(camera_pos - inputs.position); vec3 N = normalize(inputs.normal); vec3 L = normalize(light_pos - inputs.position); float NdV = dot(N, V); float NdL = max(0.0, dot(N, L));
Priority is to performs the outline detection. If outline condition is reach, exit with black color.
if (NdV < mix(unlit_outline_thickness, lit_outline_thickness, NdL)) { return; } vec3 baseColor = getBaseColor(basecolor_tex, inputs.sparse_coord);
Introduce some jitter to mask size, based on base color luminance
float maskRadiusJitter = pow(dot(baseColor, vec3(0.3333)), 0.1);
Compute a mask value, based on screen space position of fragment. This will create a grid like pattern.
float mask = pow(1.0 - length(fract(gl_FragCoord.xy / 7.0) - vec2(0.5)), maskRadiusJitter * 5.0) * 5.0;
Here, we sample the base color and apply a simple diffuse attenuation
vec3 color = baseColor * NdL; diffuseShadingOutput(mask * color); }