Author Topic: multiple textures  (Read 8495 times)

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
multiple textures
« on: September 06, 2015, 12:26:40 am »
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


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: multiple textures
« Reply #1 on: September 06, 2015, 02:43:48 pm »
Using one or at least as few as possible is the better solution, because it reduces draw calls by a huge amount.

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Re: multiple textures
« Reply #2 on: September 06, 2015, 05:54:27 pm »
ok in jpct for desktop i started to use textureMatrix, but how muh is a few???
what is a reasonable number of used textures

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: multiple textures
« Reply #3 on: September 06, 2015, 09:05:46 pm »
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.

Offline Gatobot14

  • int
  • **
  • Posts: 64
    • View Profile
Re: multiple textures
« Reply #4 on: September 07, 2015, 03:41:21 am »
ok , yeah in the end i think both ways have to be use but i have better understanding now