Low Poly Precision Outline Shader (Mobile, Web, Desktop)

Full Shader @ https://sol-vin.itch.io/low-poly-pos

Draws precision outlines using precomputed surface maps. 

Requires a screen space quad, as well as a pre-computed material which can be made using the support scripts at the website.

Shader code
shader_type spatial;
render_mode depth_prepass_alpha, cull_disabled, ambient_light_disabled, specular_disabled, specular_occlusion_disabled;

#include "res://addons/outline_shader/shaders/colors.gdshaderinc"

void fragment() {

	float polygon_color_id = pack_color_id(floor(UV2.y/float(TOTAL_COLORS+2u)));
	float outline_color_id = pack_color_id(round(mod(UV2.y, float(TOTAL_COLORS+2u))));
	
	float surface_id = UV2.x + dot(NODE_POSITION_WORLD, vec3(0.37, 0.11, 0.23));
	
	#if CURRENT_RENDERER == RENDERER_COMPATIBILITY
	    vec3 color = linear_to_srgb(vec3(mod(surface_id, 0.9)+0.05, polygon_color_id, outline_color_id));
	#elif CURRENT_RENDERER == RENDERER_MOBILE || CURRENT_RENDERER == RENDERER_FORWARD_PLUS
	    vec3 color = vec3(mod(surface_id, 0.9)+0.05, polygon_color_id, outline_color_id);
	#endif
	EMISSION = color;
	ALBEDO = color;
	//ALPHA = 1.0;
}
Live Preview
Tags
outline, pre-compute
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.

Related shaders

guest

6 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
tentabrobpy
24 days ago

I’m curious what the admin will think of someone advertising a paid asset 😸

tentabrobpy
22 days ago
Reply to  sol-vin

If the shader’s meant to be free you should provide the contents of colors.gdshaderinc as well

tentabrobpy
20 days ago
Reply to  sol-vin

Then the “free shader” is nonfunctional and serves solely as an advertisement for the paid asset. I respect the hustle but c’mon, be honest 😂