anyone that could tell me how I can get this working with this shader + script? the color array doesnt seem to be passed to the shader from the gd script and I do not understand why ```swift
extends Node
@export var colors: Array[Color] = [Color.from_rgba8(172, 67, 47)]
var shader_material: ShaderMaterial;
func _ready() -> void:
shader_material = get_child(0, true).get_active_material(0) as ShaderMaterial;
var texture: CompressedTexture2D = shader_material.get_shader_parameter("albedo_texture");
colors = FileUtils.get_colors_from_palette(texture, 4, 8);
shader_material.set_shader_parameter("fallback_color", Color(1, 1, 1, 1))
apply_palette_to_shader()
func apply_palette_to_shader() -> void:
var packed_array := PackedVector4Array()
for color in colors:
packed_array.append(Vector4(color.r, color.g, color.b, color.a))
shader_material.set_shader_parameter("filter_colors", packed_array)
shader_material.set_shader_parameter("palette_size", colors.size())
```swift
shader_type spatial;
render_mode depth_prepass_alpha;
uniform sampler2D albedo_texture : source_color;
uniform vec4 filter_colors[1];
uniform vec4 fallback_color : source_color = vec4(0.0, 0.0, 0.0, 0.0);
uniform int palette_size = 1;
const float COLOR_THRESHOLD = 0.01;
bool is_allowed(vec4 color) {
for (int i = 0; i < palette_size; i++) {
if (distance(color.rgb, filter_colors[i].rgb) < COLOR_THRESHOLD) {
return true;
}
}
return false;
}
void fragment() {
vec4 tex_color = texture(albedo_texture, UV);
if (is_allowed(tex_color)) {
ALBEDO = fallback_color.rgb;
ALPHA = fallback_color.a;
} else {
ALBEDO = tex_color.rgb;
ALPHA = tex_color.a;
}
}