Skip to content

Instantly share code, notes, and snippets.

@hiulit
hiulit / create_polygon_from_sprite.gd
Created June 8, 2020 12:41
Create a Polygon2D from a Sprite in Godot
# Thanks to Justo Delgado - a.k.a mrcdk (https://github.com/mrcdk) - for the function this one is based on.
# It can be found here https://github.com/godotengine/godot/issues/31323
# The sprite parameter must be a Sprite node.
func create_polygon_from_sprite(sprite):
# Get the sprite's texture.
var texture = sprite.texture
# Get the sprite texture's size.
var texture_size = sprite.texture.get_size()
# Get the image from the sprite's texture.
@hiulit
hiulit / outline-gles2.shader
Created September 20, 2019 19:08
Godot 3 Outline Shader GLES2
shader_type canvas_item;
uniform float width;
uniform vec4 outline_color : hint_color;
void fragment()
{
vec2 size = (vec2(width) * TEXTURE_PIXEL_SIZE);
vec4 sprite_color = texture(TEXTURE, UV);