diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2022-05-31 21:11:46 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2022-05-31 21:11:46 -0600 |
commit | 227095a4f710ac6afd43f0a7e8b296f188cf20be (patch) | |
tree | e2f7e6a323ca4cad92b6a6012ed01a1afaf517fa /src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader | |
parent | bd197168c39551c3456099ed2a39375a8442483f (diff) |
add working gif maker
Diffstat (limited to 'src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader')
-rw-r--r-- | src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader b/src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader new file mode 100644 index 0000000..8379108 --- /dev/null +++ b/src/addons/GifMaker/godot-gdgifexporter/gdgifexporter/lookup_color.shader @@ -0,0 +1,19 @@ +shader_type canvas_item; +render_mode unshaded; + +uniform sampler2D lut; + +void fragment() { + vec4 color = texture(TEXTURE, UV); + float index = 0.0; + if (color.a > 0.0) { + for (int i = 0; i < 256; i++) { + vec4 c = texture(lut, vec2((float(i) + 0.5) / 256.0, 0.5)); + if (c.rgb == color.rgb) { + index = float(i) / 255.0; + break; + } + } + } + COLOR = vec4(vec3(index), 1.0); +}
\ No newline at end of file |