Toon Shader inspired by Genshin Impact

I create simple Toon Shader inspired of Genshin Impact. not very similar, but enough for the games I’m working on.

Shader code
shader_type spatial;
render_mode cull_disabled;

uniform sampler2D image_texture: hint_albedo ;
uniform sampler2D toon_ramp: hint_albedo ;
uniform float rim_power: hint_range(1,100) = 1.0;
uniform float rim_size: hint_range(0,1) = 0.3;

void fragment() {
	vec4 color = texture(image_texture, UV);
	ALBEDO = color.rgb;
	ALPHA = color.a;
	ALPHA_SCISSOR = pow(0.1, color.a);
}

void light() {
	float shadow = clamp(dot(NORMAL, LIGHT), 0.0, 1.0);
	float rim = (shadow * (clamp(dot(NORMAL, VIEW), 0.0, 1.0) < rim_size ? 1.0 : 0.0)) ;

	vec4 processed_shadow = texture(toon_ramp, ((shadow * ATTENUATION)).xy);
	
	DIFFUSE_LIGHT += (processed_shadow.rgb + (rim*rim_power)) * ALBEDO  * LIGHT_COLOR;
}
Tags
3d, genshin impact like, 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.

Related shaders

impact shader

Shield with impact waves

Energy shield with impact effect

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
subpixelmessage
2 years ago

Awesome shader!

Last edited 2 years ago by subpixelmessage