1
\$\begingroup\$

I'm working on new game, this time moving to more 3d objects and open gl es 2. Previous (successful) game was open gl es 1 and mostly 2d. For es 2 I'm developing my own 3d engine.

My 3d artist delivers .obj's each with a texture map for base and one for bump (normal). I already have a way to import them all into a single vbo. But combining the textures is a more challenging problem.

In the es 1 game I did a couple of large texture atlases and could have them all loaded at once. But since all my geometry was just boxes it was easy to shift them around (small number of vertex) to fit. I stacked gfx like tetris pieces to fit everything in. For this though it's a bigger pain to combine textures as there are many many more vertices and they're already mapped to these individual textures.

I have several ideas for ways to approach the problem:

  1. Keep the separate but manage the loading and releasing of texture images better, so that when a level is loaded it loads just the images needed for the objects needed for the level. If I did this how many images can the ios implementation handle? How would performance suffer on older devices like the iPhone 4?

  2. Combine multiple textures into atlases and cram image parts together however necessary to fit. Then load the obj's into my 3d app and basically manually remap everything to the combined texture. It's a pain and basically what I'm paying the 3d artist to do.

  3. Combine multiple textures into atlases but by putting 4, 8, 16, etc smaller ones into each larger one.. DON'T cram them together but uniformly shrink each one. Then the remapping can be mathematical instead of a manual remapping. (This would leave possibly a lot of un-used space in some of the sub-textures)

    1. Pre-calculate the math beforehand in the importing process.

    2. Modify my shader to shrink and offset the textcoord on the fly by an amount provided as a uniform.

Also.. is it better to combine the base texture and normal texture into one or have 2? Combining them would mean having the shader do math to move the textcoord over for the normal map.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

The less times you have to send texture data through the pipeline for rendering the better. A single larger texture set would be more efficient than 1,000 smaller ones of the same memory capacity. It is not uncommon for developers on limited platforms, or developers trying to push the limits of consoles (even today) to pack textures and limit the amount of texture set calls necessary. Packing a texture atlas is a relatively easily automated process, and the extra effort up front reduces the run time performance hits.

\$\endgroup\$
2
  • \$\begingroup\$ Between my options of 2, 3A and 3B? Any suggestions? I'll probably mix the two.. have the 3d artist fit textures in to one sheet for a batch of items, but then match that batch with 3 others to make a larger sheet. Not sure yet though. I'll need to do testing. It's just that sometimes I get hung up on decisions like this. \$\endgroup\$
    – badweasel
    Commented Apr 28, 2013 at 0:23
  • 1
    \$\begingroup\$ You could write a program to automate the entire process by batching all of the chosen textures into the most suitable multiple of 2, or into multiple atlas' if necessary, and then adjust the UV coordinates in the model to be relative to texture atlas. I would try to limit the amount of hand edited values in this process, as it would lead to errors. \$\endgroup\$
    – Evan
    Commented Apr 28, 2013 at 0:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .