cheap Toon shader [quick dirty code]

I am working on toon shader for Godot 4. As part of my shader projects, I made quite many godot shaders, for different uses. Water/ocean, toon and many more are coming. Small shader snippets are also published as separate posts such as this fresnel shader.

Shader code
shader_type spatial;

uniform vec3 color: source_color;

// Cel shader
void light() {
	float diffuse_intensity = dot(NORMAL, LIGHT) > 0.5 ? 1.0 : 0.0;
	DIFFUSE_LIGHT = diffuse_intensity == 0.0 ? color / 2.0 : color;
	
	float specular_intensity = dot(NORMAL, LIGHT) > 0.990 ? 1.0 : 0.0;
	SPECULAR_LIGHT = color * 2.0 * specular_intensity;
	
	float rim_dot_product = 1.0 - dot(VIEW, NORMAL);
	float rim_intensity = pow(smoothstep(0.0, 2.0, rim_dot_product) * 2.0, 4);
	DIFFUSE_LIGHT += rim_intensity;
}
Tags
cel, cel shader, fresnel, Low Poly, Spatial, toon, toon shader
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from mujtaba-io

3D fire shader

Gerstner Wave Ocean Shader

Ray marching ocean waves + atmosphere

Related shaders

Simple, cheap stylized tree shader

Cheap water shader

Cheap caustics

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments