Many or few textures (performance)

Hello,

I have two modes to continue programming a hexagonal map in this moment, and I don’t know what way is better. Maybe you can help me :slight_smile:

I used a texture to represent the “grid”, so the squad with this texture is static and don’t move or edit in runtime.


In the first hand, I have a texture to 7700x6736 pixles, however, his size it’s only 3.131KB, when I run in Unity, the frame rate it’s nice (constants 60fps with VSynk and +100 without VSynk)

This texture is associated in one transparent material to the squad (2 triangles)

With the second mode, I have a 14 textures to 550x496 pixels and 21KB. But with this mode, I need 14 squads (28 triangles against 2) and 14 materials with differents textures, against 1 in the other way.

Too, with this second mode, I need asking the distance of every squad to hide or not hide (a simple occlusion culling)

What is the better way in your opinion?
Thanks very much! :slight_smile:

I’m no expert, but I would think with 1 texture vs 14 textures, it’d be 1 texture every time? 1 draw call vs 14, if I’m right?

If all you’ve got is 2 tris per quad, you might find occlusion culling to be an unnecessary extra overhead unless you’re planning on putting more tris onto the quads later.

I think same, but, not is very big a texture to 7700x3736? I don’t know what is important to performance. The size in KB or the size in pixels

Why not use one small texture repeated:

1514785--86222--$TiledHexesRectangleUnit.png

Or a small texture over a more complicated mesh if you want to be able to adjust tiles individually.

Both far out perfrorms either of the original options.

Thanks for reply JohnnyA.

The texture I uploaded is plane, but in real action, each hexagon has a different texture, so I will create a custom texture to every map in the game.

What do you mean with this:

Each hexagon is stored in a Dictionary and I can get their position. The mesh of the grid never changes, so I don’t need change each hexagon in the mesh, only change their texture when I load the new map

In fact, the result I want is something like this:
1514799--86224--$hexagon_Map_Forum.jpg

I’m fairly sure that your video card is not drawing a 7k x 7k texture at runtime. That may be your source resolution, but it’s most likely being resized down to 4k, since that’s about as high as video cards can be relied upon to handle.

So, if I want a big map, for example, 140x140 hexagons (the example of this thread) the better option is slice the map in various textures, no? But, 14 materials not is much? If I hide the render of one squad, their materials don’t consume very much?

I meant draw the mesh as a hexagon mesh (or a plane per hex if you want to save on tris), tris are relatively cheap. It also makes a few other things simpler (collision detection, apply effects, etc).

If I understand good, you say that I will create a mesh per hexagon. If I did that, I will have 19.600 draws in a 140x140 map! If I merge all planes in one, I will have 1 draw, but with 39.200 triangles.

Is that what you meant?

I doubt you want to draw your entire map on screen at once, but yes the general idea is that you use a lot of tris and not many textures. Big textures and texture swapping tend to have a lot more impact than a large number of tris.

Having various GameObject (about 625, the view screen is about 25x25) with Transforms and other things (renderfilter, etc…) and with various materials (If I use a simple texture to hexagon, I will need change main color to represent differentes hexagons in the map) is better than various textures?

I don’t know, but I think the gameobjects system, requieres more calculations for the CPU/GPU, no? 3KB is very big to the VRAM or the problem is their resolution?

The hex based game I built has around 12 GO’s per hex (not all active), it supports maps up to 50x50 for a total of 30,000 GO’s. It runs smoothly on ipad 2. So no I don’t think number of GO’s will be an issue.

I thought it would be bad for performance. Thank you very much for the clarification.