DGuy
March 13, 2022, 5:46pm
1
Hi,
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?
Thanks,
David
britzl
March 13, 2022, 7:55pm
2
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?
DGuy
March 14, 2022, 7:02pm
4
Bug report submitted.
And it seems the problem also occurs when just using the default sprite materials and default render-script.
opened 06:52PM - 14 Mar 22 UTC
bug
**Describe the bug **
Using resource.set_texture on any sprite, changes texture… on ALL sprites using same atlas
**To Reproduce **
1. Create an empty project
2. Create two sprites using the same atlas (The sprites can refer to same image within atlas, or different images)
3. Use example code from 'resource.set_texture()" entry in API docs to update texture of one of the sprites
4. Both sprites have been updated to use new texture
**Expected behavior **
Only sprite referred to in call to 'set_texture' should have it's texture updated.
**Defold version: **
- Version 1.3.0
**Platforms : **
- Platforms: Android, MacOS
- OS: Android 8.0.0; MacOS Montery 12.1
- Device: LG G6
**Minimal repro case project: **
There are two attachments: One using custom sprite materials & custom render-script, one using the default sprite materials & default render-script
[SetTextureProblem_customMaterials.zip](https://github.com/defold/defold/files/8247741/SetTextureProblem_customMaterials.zip)
[SetTextureProblem_defaultMaterials.zip](https://github.com/defold/defold/files/8247742/SetTextureProblem_defaultMaterials.zip)
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.
DGuy
March 15, 2022, 9:29pm
6
After some quick tests, I see by assigning sprites whose texture I want change to their own individual atlases, everything works as expected.
Thanks
3 Likes