Allow spritesheets to be used with Tile ScaleType

I want to use spritesheets to pack lots of different icons together, and I sometimes want to display these icons tiled on an ImageLabel using ImageLabel.ScaleType = Enum.ScaleType.Tile. At the moment this does not work because of how both features are implemented:

(from my original bug report ImageRectOffset/Size does not work with Tile ScaleType)

Another way of looking at this problem is that the way an image is displayed (ScaleType) is coupled together with the way image assets are stored, managed, etc (spritesheets via ImageRectOffset/Size).

So at the moment if I want to achieve image tiling I need to A) reupload the tiled portion of the spritesheet as an individual image asset which can be used with the Tile ScaleType, or B) make a separate ImageLabel for every tile with each ImageLabel configured to show the same sprite from the spritesheet.

Being a bit more nitpicky on the details, from my perspective as a developer the ImageRectOffset/Size and ScaleType properties should have no effect on each other: the ImageRectOffset/Size properties get applied first (to decide which part of the spritesheet to use) and the ScaleType property last (to decide how to stretch the rendered image). All the other ScaleTypes seem to work fine in this way, it’s just the Tile ScaleType that doesn’t play nicely.

11 Likes

Bump, this would be a very good addition for animated tiled textures and many other applications. The fact there’s no clean solution to this (from what I know) in-engine is absurd.

2 Likes

Fully agree. The way the roblox team will work on anything except bare minimum game engine features (looking at you ResampleMode for anything thats not imagelabel) and it is infuriating. This is a feature which should be extremely easy to add AND at the same time would have a TON of use cases for developers. Instead, every developer who wants to do something like this has to do very hacky workarounds that are ALSO very unperformant. Small features like these that should have been added a while ago should be at the TOP of the priority list for roblox.

3 Likes

Worth noting that this is not a very fair thing to say. The OP had a very clearly listed technical reason this was not implemented: the tiling is implemented via UV tiling.

If you do not understand what that is, it’s the equivalent of zooming out the texture (filling any void area with copies of the texture), whereas using ImageRectSize is like zooming in the image. You can’t both zoom in and zoom out an image at the same time using the same technique. Roblox engineers would need to implement new functionality to support this, it’s not something they can just “enable”.

I don’t think you actually understand how UV tiling works. It isn’t just “zooming in” and “zooming out”.
Most implementations of UV tiling are done in a fragment shader and can very easily be accomplished with uv = fract(uv * TILE_SIZE) and it would be safe to assume roblox does something similar to this as well. Again, you aren’t zooming in and out, you are getting the UV for every single pixel and modifying it to tile.
After this step, you could literally add image rect offset/size in a single line of code by mapping the UV ranges to the ranges of a rect.
You can make a shader and replicate this in any program of your choice. Here is something I made in 5 minutes using shadertoy.
Tiling without rect:


Tiling with rect:

1 Like

Roblox implements tiling with a simple repeating texture (GL_REPEAT) using the vertex uv coordinates and not at all through fract() in the fragment shader. They certainly could do that but it’s probably not much of a priority for them compared to other features and fixes.

2 Likes