Animated sketchy line

A sketchy outline material for Godot Engine.

This is a multipass shader that works best with 2 passes: the one provided, and an additional one with cull_back and slightly different parameters. Please see the material configuration on itch.io

Warning: does not work well on hard surfaces and meshes with large flat areas.

Shader code
shader_type spatial;
render_mode cull_front, unshaded;

uniform sampler2D outline_noise_tex;
uniform vec4 outline_color:hint_color;
uniform float scissor_value = 0.5;
uniform vec2 uv_scale = vec2(1.0);
uniform sampler2D falloff_curve;
uniform float outline_size = 0.1;
uniform float offset_fres = 0.3;
uniform float fps = 5.0;

varying float h;

void vertex(){
	VERTEX += NORMAL * outline_size * texture(outline_noise_tex, UV).r;
	h = (WORLD_MATRIX * vec4(VERTEX, 1.0)).y;
}

void fragment(){
	float fres = abs(dot(normalize(-NORMAL), normalize(VERTEX)));
	vec3 nor = normalize(NORMAL);
	float angle = atan(nor.y, nor.x);
	angle /= 3.14;
	
	float fres_remap = texture(falloff_curve, vec2(1.0 - fres)).r + offset_fres;
	ALPHA = texture(outline_noise_tex, vec2(angle * uv_scale.x + SCREEN_UV.x, nor.z * uv_scale.y + floor(TIME * fps)/fps)).r * fres_remap;
	ALBEDO = outline_color.rgb;
	ALPHA_SCISSOR = scissor_value;
}
Tags
multipass, outline
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 QbieShay

Spatial particle shader

Texture mix example

Particle Process V2

Related shaders

Sketchy renderer with optional shadow and tinting.

Hex Line Shader

Line Rendering Solution

Subscribe
Notify of
guest

5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
gyrosp
gyrosp
3 years ago

Hi, I’really like your shader :).
Will this also work on a 2D-Surface?

I tried to make it work but unfortunately without success.
What do you mean with cull_back?
I’m new to shader and godot.
Could you please provide a sample project?

Best regards
gyrosp

last_bender
last_bender
8 months ago

Hi,

I couldn’t manage to run this. I think it’s for Godot 3.x but not for 4.x Is that correct?

Thanks

LyDek
LyDek
7 months ago
Reply to  last_bender

to make it work with Godot 4, change “hint_color” into “source_color” at line 5, and “ALPHA_SCISSOR” into “ALPHA_SCISSOR_THRESHOLD” at line 29

tvvr
tvvr
3 months ago
Reply to  LyDek

and MODEL_MATRIX to MODEL_MATRIX