(SOLVED) Resource.set_texture affects sprites with different materials


When I use resource.set_texture() to change a sprites texture, sprites with different materials are also affected.

I have two sprites, each sprite using a unique material, each material with a unique tag. The new materials also make use of the stencil buffer .

Also I’ve updated the render-script to draw sprites using these unique materials before those using the default sprite material.

When I update the texture of one of the sprites, both sprites are rendered using the new texture and, also, both ignore the stencil buffer.

It seems set_texture reverts the sprites to use the default sprite material.

Is this known/expected behavior or does it sound like a bug?


Sounds like a bug, but we’d like to look into this a bit more closely. Could you please create a ticket on GitHub and include a small project where this can be tested?

Bug report submitted.

And it seems the problem also occurs when just using the default sprite materials and default render-script.

1 Like

I think you explained your problem in your issue here:
“Using resource.set_texture on any sprite, changes texture on ALL sprites using same atlas”

That is true, if you replace the texture, you replace the entire texture.
We currently don’t have support to update a region of the texture.

After some quick tests, I see by assigning sprites whose texture I want change to their own individual atlases, everything works as expected.