View-MatCap

View-Matcap shader

The matcap texture is applied from the surface normals in the view-space (the texture follows the camera).  It can be used to fake complex materials with reflections and lighting for mobile devices. Matcaps are typically used in software like blender and zbrush.

Shader code
/*
	MatCap Shader by Firerabbit
	
	MIT License
*/

shader_type spatial;

uniform sampler2D matcap : hint_black_albedo;
uniform float metalness : hint_range(0.0,1.0) = 1.0;
uniform vec4 color : hint_color = vec4(1.0);

void fragment() {
	vec2 matcap_uv = (NORMAL.xy * vec2(0.5, -0.5) + vec2(0.5, 0.5));
	ALBEDO = color.rgb;
	ALBEDO *= mix(vec3(1.0), texture(matcap, matcap_uv).rgb, metalness);
}
Tags
capture, matcap, material, view
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Firerabbit

Dither opacity with GLES2 Support

2D Pixelart Upscaler/Filter

Toon Shader

guest

0 Comments
Inline Feedbacks
View all comments