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

Comments 6

    1. The shader material is free, the scripts to compile the information into the meshes are not.

      -4
      1. If the shader's meant to be free you should provide the contents of colors.gdshaderinc as well

        3
        1. I can't because the colors.gdshaderic file is auto generated by an OutlinePalette class which is one of the support scripts

          -3
          1. 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 😂

            6
          2. It's functional if you are willing to write the code to pack surface map data into each mesh. I don't make the rules, i just deftly work around them :D

            -7