Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Series of quads not slicing correctly

A topic by Scarlet String Studios created Apr 18, 2018 Views: 265 Replies: 7
Viewing posts 1 to 7

I have a  frame-by-frame animated quad that I'm using as a click-to-continue icon,  but it isn't slicing and tiling correctly. Here is the quad in question, and this is what each frame looks like when displayed in-game.

These results aren't consistent; for example, changing the scaling in Game view can make the extra line of pixels appear or disappear. So I guess it has something to do with how the texture is being downscaled (or upscaled).  A few things I've tried:

  • Slicing the sprite myself in the import settings (I think Super Text Mesh ignores this?)
  • Setting filter mode to Point in both STM and sprite import settings
  • Turning off mip maps
  • Resizing sprites so that there are a few columns of transparent pixels between each arrow

Is there a way to just slice my own sprites for use in an animated quad?

Developer (1 edit)

Hey!

Please make sure the quad texture is being imported as a texture, not a sprite. Not sure if that would be the exact cause, but that's a start. You've already tried resizing the sprites on your texture to give some space between quads, but can you try shrinking the texture even more? Quads are essentially just manual UV maps, so I think the first quad is reading info from the second and so on.


That said, there might be an issue with insanely big sprite sheets for Quads that I haven't solved yet, so this might be related to that? Hopefully shrinking the texture even more solves it, but I'm hoping it's just a certain import setting somewhere on the texture.

By texture you mean Texture Type = Default, rather than Texture Type = Sprite? That's what I'm doing right now, although I tried earlier with Sprites. I just tried a couple of smaller versions where each arrow was 64x64 and 16x16 respectively, but I'm still seeing the same problem. 

Yeah, it seems to be reading one extra line of pixels from the next quad on the sheet. How does the asset decide where to draw the line between each quad?

Developer (1 edit)

Yes, that's what I meant!

The way the math is working is... It takes the sprite sheet and uses the columns/rows setting to know how many boxes to slice the texture into. So, if there's 1 row and 3 columns and you want to read index 1 (the second image), the UV used would be... (0.3333,0), (0.66667,1)

...I think that might be it. Can you try making it so your texture is 4 units long instead of 3? (So the UVs would land on multiples of 0.25 instead of 0.3333 repeating) The UV math's float rounding might be what's pushing it over the edge? I think I might also be able to fix this by taking the far right UV (0.66667 in that example) and subtracting a very small number like 0.0001 from it. I'm away from my work computer atm, but I'll figure out exactly what line that would need to go on in just a bit!

(1 edit)

Thanks, that makes sense. It does feel like a float error because of how inconsistent it is.

Unfortunately this didn't fix the problem. I made an extra column and set the quad to loop frames 0, 1, 2, and 3.  Still looks the same as before.

I just tried a hard fix by decreasing the width of each arrow by 2px, so there's 1px of padding on each side. This fixes the problem (last time I just added padding on one side). That said, it would still be good to know what's causing the issue, if you manage to figure it out. Resizing sprites works for now, but it's not the most elegant.

Developer

Yeahhh apologies for that! I'll keep looking into it, but I'll take note of this in the docs for now! Thank you so much for your patience.

Developer

Still looking into this, because I'm still not too sure what I could have changed that could cause a difference in this between any version? I might be able to add a padding variable or something if it persists?

I can't remember if the behavior changed across versions, but a padding variable might fix it. After a while, I noticed that adding my own padding was still inconsistent at different screen resolutions, so I just created a game object for the image instead of trying to insert it as a quad. It worked for me given the situation, but enough padding might have fixed the problem too.