OpenGL ES 1.1 multiple textures per mesh
I'm very new to OpenGL, so I'm sorry if this may be very basic (or not make sense).
I'm working on a 2D game in which there are a lot of sprites whose size are not powers of two. So I'll have textures like, say, 520x260, and which cannot be redesigned. Now my understanding is that since OpenGL ES 1 needs textures to be powers of two, I'll effectively be wasting a lot of memory (since the texture in my previous example would actually take up 1024x512 on the hardware).
What I've been thinking was that instead of having the sprite be two triangles with that one large texture, I could maybe have the sprite be made up of more smaller triangles, and that I could break down to large texture in smaller pow2 chunks (say 128x128) which could be used separately on those triangles (using something like a grid map).
So my question is: is it possible and feasible to use multiple textures for a single mesh? And if so, would the extra calculations (necessary for all the smaller triangles and texturing them) be worth the texture memory save?
PS I am working on Android, but I don't suppose that makes much difference.
Absolutely you can and should do this to save memory. The only thing you need to worry about is your UV-mapping. You will have to adjust your UV coordinates based upon how you arrange your mesh.
For example, say you wanted to stuff three textures in a 128x128 mesh:
+-----------------+
|1. |
| 128x64 |
| |
+-----------------+
|2. |3. |
| 64x64 | 64x64 |
| | |
+--------+--------+
If you wanted to map each texture, your UV-coordinate ranges are as follows:
You will have to translate these accordingly onto your vertices.
I'm pretty sure the textures don't have to be the same dimensions as your sprites. If you have sprites that are 520x260, you should be able to shrink your texture to 512x256 and map it over your sprite, without noticing the slightly smaller resolution.
链接地址: http://www.djcxy.com/p/87142.html上一篇: Android opengl纹理损坏