Handling materials with the VisualServer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By snk


I created a material using the visual server, but I can’t find some SpatialMaterial related operations in the functions, like adding a texture to it.

I tried to use the material_set_param method like so :
[C#] VisualServer.MaterialSetParam(myMatRID, "albedo_texture", myTexture)
But it doesn’t work, yet I did find the property binded to the API.

Any idea on how I could access and modify all the properties of a material created with the VisualServer ?

Also, if I instanciate a material the regular way instead and then request its RID in order to handle it with the VisualServer in several other threads, as long as I don’t try to modify the resource or let the garbage collector get rid of the resource’s instance before I free all the meshes RID it’s attached to : it is going to be perfectly thread-safe or is there things I should be aware of ? Are all the resources treated the same way regarding parallelization in that case ?

Thanks for your answers.
Have a nice day!

:bust_in_silhouette: Reply From: gilzoide

If you create a SpatialMaterial and convert it to a ShaderMaterial, you can see in the shader code that the uniform is actually called texture_albedo and not albedo_texture, even if the later is the name of the SpatialMaterial’s property.

As for the second question, it seems as long as you load and modify the Resource in a single Thread, you are fine.

Hope I’m not too late answering this =P

Have a nice day as well ^^