Using RenderingServer.material_set_param to set Sampler2D parameter not working?

I am trying to set a Sampler2D parameter on a mesh/material created using the RenderingServer function but setting the Sampler2D parameter doesn’t seem to work or do anything even though using the exact same resource with the regular set_shader_parameter function on a normal mesh works just fine and setting the parameter to a String does actually set the parameter (I can print it out and see) but it doesn’t do anything. I tried setting it to a Resource like the normal set_shader_parameter and it just sets it as null every time even though the exact same resource works with the set_shader_parameter, even if make sure to keep the resource reference stored it makes no difference :confused:

I see nothing on this stuff online anywhere and the API docs for the material_set_param function is a whopping 4 words long so im pretty lost, hoping someone here can help :slight_smile:

extends Node3D

var sphere_instances: Array[RID]
@onready var sphere_mesh : RID = RenderingServer.make_sphere_mesh(64, 32, 0.5)

func _ready() -> void:
	create_mesh(0)
	create_mesh(2)

func create_mesh(origin : int) -> void:
	# Create and store mesh instance
	var sphere_instance : RID = RenderingServer.instance_create()
	sphere_instances.append(sphere_instance)

	# Create shader materials
	var material : RID = RenderingServer.material_create()
	var body_shader : RID = RenderingServer.shader_create()
	var body_code : String = FileAccess.get_file_as_string("res://gfx/shaders/stellar_body.gdshader")
	RenderingServer.shader_set_code(body_shader, body_code)

	RenderingServer.material_set_shader(material, body_shader)	
	var resource : Resource = preload("res://gfx/Terrestrial/Terrestrial5.dds")
	
	# Setting Sampler2D on a normal mesh material works fine.
	$MeshInstance3D.get_active_material(0).set_shader_parameter("albedo_texture", resource)

	# Setting a parameter that is not a Sampler2D works fine.
	RenderingServer.material_set_param(material, "albedo_mod", 2.0)
	print(RenderingServer.material_get_param(material, "albedo_mod"))

	# Trying to Sampler2D param on a material created with RenderingServer.material_create() does not work...
	# Have tried all the ways I can think of none of them do anything.
	# The second 2 here actually set the parameter but do not work in the shader.
	RenderingServer.material_set_param(material, "albedo_texture", resource)
	#RenderingServer.material_set_param(material, "albedo_texture", "res://gfx/Terrestrial/Terrestrial5.dds")
	#RenderingServer.material_set_param(material, "albedo_texture", "gfx/Terrestrial/Terrestrial5.dds")
	print(RenderingServer.material_get_param(material, "albedo_texture"))
	
	RenderingServer.mesh_surface_set_material(sphere_mesh, 0, material)

	# Set base, scenario, and transform on RID
	RenderingServer.instance_set_base(sphere_instance, sphere_mesh)
	RenderingServer.instance_set_scenario(sphere_instance, get_world_3d().scenario)
	RenderingServer.instance_set_transform(
		sphere_instance, Transform3D(Basis.IDENTITY, Vector3(origin,0,0))
	)

If you can’t use a Resouce or a String and only Variant types can be passed in (according to the API docs for RenderingServer.material_set_param) what is the intended way to do this?