★ TouchArcade needs your help. Click here to support us on Patreon.

OpenGL ES Texture Mapping

06-08-2009, 09:35 PM
#1
Joined: May 2009
Location: Ky
Posts: 7
OpenGL ES Texture Mapping

Quick question for you developers out there. I was wondering if it would be more economically efficient (require less memory) if I use the same image for 4 textures? For example. say I have a square image, every quarter of that square has a different image, can I take that image and basicilly use it as four different textures? If so does the image degrade very much? Thanks for any help.

Last edited by Raithwall; 06-08-2009 at 09:37 PM.
06-08-2009, 10:08 PM
#2
Joined: Oct 2008
Location: Toronto Canada
Posts: 863
It won't use less memory but it will cut down on texture uploads which is definitely a plus. Apple recommends this technique in their documentation (Google "texture atlas") but there are some caveats so it may not work for all situations.

SHREDD GO FAST! FREE!
Nozoku Rush Kick Math's Ass!
Critter Panic Break yer brain! FREE!
Silverfish & Silverfish MAX Hardcore arcade insanity!
Nozoku A casual game of math & logic.
More: cbox.me Twitter YouTube
06-08-2009, 11:43 PM
#3
Realmaze3D uses this technique extensively...there are normally only 5 actual textures visible: 1 for walls/floor/ceiling (1024x1024 texture divided into 3x3 square segments for a total of 9 'textures'), 1 for the various decorations (512x512 divided arbitrarily depending on objects), 1 for ladders (512x512 also arbitrarily divided), 1 for light halos (64x64 divided into 2x2 square segments), and 1 for the UI stuff (256x256 divided arbitrarily). The biggest problem is probably preventing mipmap bleeding. Also getting the walls/floor/ceiling texture segments to tile took quite a bit more work than usual, although that's partially because the 3 wall sections have to tile with each other (same for floor and ceiling).

--Eric

Realmaze3D on the App Store
Realmaze3Free: 3 free mazes (a taste of Realmaze3D)
06-09-2009, 12:55 AM
#4
Joined: Oct 2008
Location: Toronto Canada
Posts: 863
Quote:
Originally Posted by Frank Condello View Post
... it will cut down on texture uploads...
To be clear, I should've said: *can* cut down on texture uploads. Ideally your atlases should only be bound once per frame - bind once, draw lots. Same goes for other GL state changes.

SHREDD GO FAST! FREE!
Nozoku Rush Kick Math's Ass!
Critter Panic Break yer brain! FREE!
Silverfish & Silverfish MAX Hardcore arcade insanity!
Nozoku A casual game of math & logic.
More: cbox.me Twitter YouTube