A new texture file for every copy of a mesh

Godot Version

Xogot

Question

I’m working on a procedural generation project, and to that end it would be really useful if I could “bake” the ouptut of a shader into a new texture. I already sort of know how to do this with a subviewport, but the problem is every copy of the texture gets saved in the same file. Is there a way that I can set it up so that each time I create a new mesh with the shader holding this texture, it spawns a new file unique to that individual instance of the mesh?

Well change the filename for each instance.

The problem is that I do not know in advance how many instances I will need to spawn.

Why do you need to know that?

I should clarify: I don’t know how to change the filename for each instance other than going in and doing it manually. If you know how to do it automatically, that is exactly the information I’m looking for!

Maintain a counter that you increment by one with each new texture and create a name that has its value as a suffix.

2 Likes