This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
manual:texture_formats [2013/05/28 16:03] – [PVR] daniel | manual:texture_formats [2013/05/30 12:03] (current) – [Size Limits] daniel | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Texture formats ====== | ||
+ | There are different file formats available which can hold your textures. The format you are using can have influence on memory consumption. | ||
+ | |||
+ | === Size Limits === | ||
+ | |||
+ | Before we look at the actual formats, there is one thing you have to be aware of. Regardless of the file type, the maximum texture size is limited, depending on the device the game is running on. If you load a texture that exceeds this size, the app will crash! | ||
+ | |||
+ | ^ 1024 x 1024 ^ 2048 x 2048 ^ 4096 x 4096 ^ | ||
+ | | iPhone 2G | iPhone 3GS | iPhone 4S + 5 | | ||
+ | | iPhone 3G | iPhone 4 | iPad 2 (since iOS 5.1) | | ||
+ | | | iPad 1 | iPad 3 + 4 | | ||
+ | |||
+ | < | ||
+ | </ | ||
+ | |||
+ | ===== PNG ===== | ||
+ | |||
+ | Since most textures in 2D games contain an alpha channel, [[wp> | ||
+ | |||
+ | It is, however, also the format that takes up the most space in graphics memory. | ||
+ | |||
+ | **Graphics Memory** | ||
+ | |||
+ | A PNG image stores 4 channels for every pixel: red, green, blue and alpha, each with 8 bit (that makes 256 values per channel). It's easy to calculate how much space a 512x512 pixel texture takes up: | ||
+ | |||
+ | < | ||
+ | 512 x 512 pixels x 4 bytes = 1,048,576 bytes = 1 MB | ||
+ | </ | ||
+ | |||
+ | Quite a lot for such a small texture, right? Beware that PNG's built-in file compression does not help: the image has to be decompressed before OpenGL can handle it. | ||
+ | |||
+ | Nevertheless: | ||
+ | |||
+ | However, there might come a moment in the development of your game where your memory consumption is higher than what is available on the device. | ||
+ | |||
+ | This is the right time to look at the PVR image format. | ||
+ | |||
+ | |||
+ | ===== PVR ===== | ||
+ | |||
+ | The graphics chips of all current iDevices are developed by [[wp> | ||
+ | |||
+ | Now that's the important part: a PVR texture will take up almost exactly as much space in graphics memory as it does on your hard drive! That's the main difference to PNG textures, and that's the reason why PVR textures are so special. | ||
+ | |||
+ | The downside is that you probably can't display or save that format in the image editor of your choice. You have to use special tools for that. | ||
+ | |||
+ | There' | ||
+ | |||
+ | ===== JPEG ===== | ||
+ | |||
+ | I don't think I need to tell you much about the [[wp> | ||
+ | |||
+ | JPEG is a lossy compression format. That means that your images will lose quality when you save them with JPEG (yes, even when you're using the maximum quality setting). In exchange, the compression rate is very good. However, what I said about the PNG format holds true here, too: the GPU doesn' | ||
+ | |||
+ | The main problem with JPEG, though, is that it does not have an alpha channel. For most of the textures in your game, this will be a show-stopper, | ||
+ | |||
+ | For that reason, the recommended way to use compressed, lossy textures on iOS is [[PVR Textures|PVRTC]]. Not only does it have an alpha channel, but it can be used in its compressed form by the GPU. | ||
+ | |||
+ | |||
+ | ----- | ||
+ | |||
+ | //Next Section: [[PVR Textures]]// |