View-MatCap

View-Matcap shader

Godot 4

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 : source_color, hint_default_black;
uniform float metalness : hint_range(0.0,1.0) = 1.0;
uniform vec4 color : source_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

Generalized Kuwahara

2D Pixelart Upscaler/Filter

Terrain Mesh Blending with Dithering

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Unhinged Dev
1 year ago

amazing, super simple, perhaps u can update it to follow the cameras position aswell?