On this page
Matcap
The Matcap (Material Capture) lighting model is a screen-space shading technique that uses a pre-rendered texture (the matcap) to simulate complex lighting and reflections without requiring actual scene lights. The texture encodes how a material responds to light from every viewing angle, effectively “capturing” the look of a specific lighting setup.
Originally popularized in sculpting software like ZBrush and Blender. Model allows to visualize materials with minimal performance cost. The lighting effect is achieved by mapping the view-space normal direction of each pixel into the matcap texture, so that the color lookup directly represents the material’s response to light from that view angle.
Visual demo¶
Complete per-vertex and per-pixel implementations, with detailed comments, are available on Patreon.
// Pseudo-code (Complete per-vertex and per-pixel implementations, with detailed comments, are available in the related Patreon post)
// Inputs: normalWS - world-space normal
// Output: matcap color based on view direction
// Convert normal to view space
half3 normalVS = normalize(TransformWorldToViewDir(normalWS))
// Map to [0,1] UV space
half2 matcapUV = normalVS.xy * 0.5 + 0.5
// Lookup color
half3 col_matcap = SAMPLE_TEXTURE2D(BaseMap, samplerBaseMap, matcapUV).rgb
// Apply contrast
col_matcap = pow(matcapColor, _MatcapContrast.xxx)
// Adjust brightness
col_matcap *= _MatcapBrightness
// Tint and output
half3 col_output = col_matcap * _Tint.rgb
return half4(col_output, 1.0)
Basic idea¶
The normal direction of each pixel (in view/camera space) determines where to sample from the matcap texture.
The texture itself encodes precomputed lighting and reflection information. Basically, it’s a “snapshot” of how a material looks under a specific lighting environment.
Because the lookup depends on the view-space normal, the shading automatically reacts to camera movement, mimicking real reflection behavior without actual scene lighting.
This approach completely bypasses dynamic lights, shadows, or specular calculations. It’s effectively image-based lighting, but baked into a 2D texture.
Matcap Equation¶
d = T(N_v.xy / 2 + 0.5) ^ Îł x b x Tint
Where:
- N_v: surface normal. Transformed into view space
- T(UV): matcap texture sample
- Îł: contrast exponent
- b: brightness factor
- Tint: per-material color parameter
Matcap shading shows that a single texture can fake complex lighting, reflections, and material depth. It is fast and flexible, and it fits stylized rendering.
This lighting model remains one of the most elegant tricks in a technical artist’s toolbox. Sometimes, less really is more.
đź”— Related Functions¶
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.