Can't replace image in atlas

I’ve been trying to achieve the Modify atlas example in my own project for modding support with no luck so far. It seems like the example code gets the wrong UV coordinates, especially if the target image isn’t on the top-left of the atlas.

Downloading and running the example as-is works fine:

But adding random junk to the atlas breaks it:

If you look closely, you can see the bottom part of the green spaceship got overwritten.

Here’s a small demo project I made to test this out and make sure I wasn’t going crazy: (4.0 KB)
The code tries to replace the orange-and-blue logo with the blue-only logo. It works when the orange-and-blue logo is the only one in the atlas, but it ends up replacing a totally different part of the atlas when another image is added.

I’m not sure whether this is a bug in the engine or just some bad example code.

EDIT: Forgot to mention I’m on 1.8.1, if it’s important.

I think the example code is bad:

Related: Add margins to the left and top edges of the atlas. by AGulev · Pull Request #8657 · defold/defold · GitHub

1 Like

I’ve already tried removing that offset, but it didn’t help. The image is off by way more than just 6 pixels.

Ok, please create a ticket on GitHub and link it here. It seems like something we should look into.

1 Like

Do you want it in the main repo or the examples repo?

Doesn’t matter. As long as it is easy to reproduce.