From 9cac98c94199e92bb9ef1975322e334123b730cb Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Mon, 2 Sep 2024 02:21:48 +0300 Subject: [PATCH] Add an alpha uniform to the IndexMap shader In case users don't want the effect to affect the alpha channel --- src/Shaders/Effects/IndexMap.gdshader | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Shaders/Effects/IndexMap.gdshader b/src/Shaders/Effects/IndexMap.gdshader index b834b1772..dc4c026dd 100644 --- a/src/Shaders/Effects/IndexMap.gdshader +++ b/src/Shaders/Effects/IndexMap.gdshader @@ -3,6 +3,7 @@ shader_type canvas_item; render_mode unshaded; uniform sampler2D map_texture : filter_nearest; // The map texture +uniform bool alpha = false; // (begin DESCRIPTION) // The Red and Green values (0-255) of tool color will be treated as an x and y position @@ -14,5 +15,8 @@ void fragment(){ vec2 map_size = vec2(textureSize(map_texture, 0)); vec2 lookup_uv = vec2(round(col.x * 255.0)/(map_size.x), round(col.y * 255.0)/(map_size.y)); vec4 index_color = texture(map_texture, lookup_uv); - COLOR = index_color; + COLOR.rgb = index_color.rgb; + if (alpha) { + COLOR.a = index_color.a; + } }