The simplest outline shader (improved)

Inspired by RPaciorek‘s outline shader.

The original moves all vertices outward from the origin – which means it won’t work (as intended) on any concave shapes. Here, we instead move outward using the NORMAL, to fix that.

Attach the shader material as a next pass.

Shader code
shader_type spatial;
render_mode cull_front, unshaded;

uniform vec3 color : source_color = vec3(0,0,0);
uniform float thickness : hint_range(0.0, 1.0, 0.01) = 0.05;

void vertex() {
	VERTEX += thickness*NORMAL;
}

void fragment() {
	ALBEDO = color;
}
Tags
outline
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 CountingClowns

simple fresnel transparency

I-Can’t-Believe-It’s-Not-Matcap (modular view-based shading)

Related shaders

The simplest outline shader (via material)

Improved frosted glass

2D Outline and Rainbow outline 2 in 1

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments