Main Menu

multiple textures

Started by Gatobot14, September 06, 2015, 12:26:40 AM

Previous topic - Next topic

Gatobot14

Hi everyone

just asking what is the best approach,
suppose i have a terrain grid and each squares uses a different texture, what its best
1) having a lot of different texture files and setting them as needed
2) have one big texture and change the uv's

for now been using number 1, but not sure if this its the best


EgonOlsen

Using one or at least as few as possible is the better solution, because it reduces draw calls by a huge amount.

Gatobot14

ok in jpct for desktop i started to use textureMatrix, but how muh is a few???
what is a reasonable number of used textures

EgonOlsen

The thing is that each change in texture means a state change for OpenGL. State changes are expensive, so you should try to avoid them anyway but in addition, polygons with a different state (i.e. texture in this case) can't be rendered in the same draw call. And draw calls are the most expensive things in OpenGL.
jPCT tries, both in compiled and hybrid mode, to minimize these by batching geometry based on the textures used, so it should be ok if a terrain uses 1-8 texture depending on the size of the terrain. But it's not a good idea to make it use 64 textures or something. As a rule of thumb, I suggest to merge textures where possible but don't go crazy on it. If it really helps your project or your art pipeline to leave some textures as individual, then do it.

Gatobot14

ok , yeah in the end i think both ways have to be use but i have better understanding now