Multiple tiles vs Stretched tilemap

I have a technical question regarding tilemaps and texture sizes. The example image below is a 1x11 tilemap using 16x16 tiles:

To use this as a horizon in a level that’s 1536 pixels wide I could either:

  1. Insert the tilemap into a game object and scale the game object by 96 in the x axis resulting in a 1536x176 texture (I assume?!?), but only 11 tiles.

  2. Use a 96x11 tilemap which would use 1056 tiles but less texture memory (Also assumed?!?)

Does anyone know if one of these methods would be less hardware intensive? Both methods perform OK but I don’t know which one to use.

The is a descriptive example, real world the numbers would be considerably bigger.

Thanks alot

Why not stretch a single sprite to the full width?

You could do the background as a pure shader on a unit quad stretched to the size of your screen too.

Re 1) The texture won’t grow because of the scaling. It will still be the original size. It’s the vertex data that gets scaled.

  1. Would consume more memory than #1, since each tile will have individual info about each cell.

As @Pkeod mentions, you would probably benefit from just using a sprite with a texture, and just scale the game object.

Thanks guys. I was using the first option anyway so will stick with this.

@Pkeod
I’m using 3 tilemaps for a parallax background in this project (the tilesource is just 16x16 solid blocks). Would you recommend I use sprites if possible (it is entirely possible but would be more work to draw the sprites externally instead of a tilemap). I should use sprites performance wise that is…?

@Mathias_Westerdahl
So if I scale a texture to large dimensions. This is ok? Lets say i scaled a game object to 200x it’s original width (like with this horizon question for example), this would have no negative impact on peformance?

1 Like

Scaling an image will not use more texture memory or anything like that but the GPU will need to draw more pixels. GPUs are very good at that, but there’s always the issue if over draw, meaning that you draw more than you need and on the same pixel multiple times.

1 Like