Can't change compressedtexture2d parameter for palette swap shader

Godot Version

Version 4.5

Question

I’m making a pixel art RPG, and I’ve made a system for swapping between different color palettes; there are 81 colors in a palette, and every sprite is drawn in a base palette where each color has a different blue value. The shader reads the blue value of a pixel and uses that as a coordinate on a palette (modified from system in this video: https://www.youtube.com/watch?v=CLqMcgDi–Y)

I wanted to make a simple test system to swap the palettes, but every time I try to change the parameter, the whole screen goes white instead of changing the palette. Everything still works, it’s just the visuals that are broken. I’ve tried everything I could think of plugging in:

extends ColorRect
var P_ROTATE=0
@onready var SHADER=material

func _input(event):
	if Input.is_action_just_pressed("north"):
		P_ROTATE+=1
		if P_ROTATE>5: 
			P_ROTATE=0
		print(SHADER.get_shader_parameter("PALETTE"))
		if P_ROTATE==0:
			SHADER.set_shader_parameter("PALETTE","res://Shaders&Stuff/Palettes/0Default.png")
		elif P_ROTATE==1:
			SHADER.set_shader_parameter("PALETTE","uid://sdbipxlsexx0")
		elif P_ROTATE==2:
			SHADER.set_shader_parameter("PALETTE","res://.godot/imported/0Default.png-9eff790735d651bf2774d1a3778e34c8.ctex")
		elif P_ROTATE==3:
			SHADER.set_shader_parameter("PALETTE","res://Shaders&Stuff/PaletteUniqueResources/0Default_.tres")
		elif P_ROTATE==4:
			SHADER.set_shader_parameter("PALETTE","res://Scenes/TestScenes/cam_with_shader.tscn::ShaderMaterial_npjlk")
		elif P_ROTATE==5:
			SHADER.set_shader_parameter("PALETTE","<CompressedTexture2D#-9223371980600768993>")

None of them worked. Most of those were desperate long shots, but I don’t understand why the image file itself doesn’t work. What am I doing wrong here?

You need to pass texture resource object, not file path string, so: load(your_resource_path)

1 Like

thank you so much! i figured it was something like that but i didn’t know what to search in the documentation