Game Development Community

Use Apple's utility for PowerVR compressed textures

by Mat Valadez · in iTorque 2D · 12/23/2008 (2:48 pm) · 5 replies

Apple ships a command-line tool for generating PowerVR compressed textures from PNG files with the iPhone SDK. The PVRTC files you create using this tool can be used directly with Torque, dramatically reducing texture memory usage. By default, the tool is installed to this path: /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool

For full usage information, run the tool without arguments. To generate a file that can be used with Torque, you must pass at least the following arguments:

texturetool -e PVRTC -o -f PVR

...where is the name of the file to be generated (which should have the ".pvr" extension) and is the image file you wish to convert. This will generate a compressed texture using four bits per pixel with no mipmaps. To generate a texture with two bits per pixel, pass "--bits-per-pixel-2". To generate a complete set of mipmaps, pass "-m".

Be sure to include the "-f PVR" argument; otherwise, texturetool will output the raw compressed texture data without any header information. Torque uses the header to determine attributes such as the dimensions and format of the compressed texture.

The texture must be square, with power-of-two dimensions. Non-square textures will not work.

For complete usage information, run texturetool without arguments. For more information about compressed textures, consult the PowerVR SDK for OpenGL ES 1.x, available at: http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES1xMBX.asp

#1
03/16/2009 (6:38 pm)
Would it be better to use PVR, or pngcrush? How significant are the compression rates?
#2
03/17/2009 (12:19 am)
PVR isn't used just because the file is smaller, but because the texture is stored in memory *in compressed format*. PVRs reduce RAM usage by a huge amount. The two options reduce it to 13% and 6% of the original size (lossily). For quality, stick to PNGs.
#3
11/19/2009 (12:53 pm)
How would this apply to sprites already in png format, already implemented into a game? Where every sprite implemented is not a power of 2?
#4
11/19/2009 (2:16 pm)
Make the sprite sheet (you are using sprite sheets…right?) a power of two :)
#5
11/20/2009 (4:37 am)
Its a lot of work Kurt, but for good performance and memory usage its critical. The plan is to plan planning ahead planning to use pvr's :)

a) Power of two is standard for games (especially 2d) - this is not something new to iPhone

b) Sprite sheets and collective images - same as above, nothing new :)

It will be noted that this wasnt clear up front and could cost you valuable time - that really sucks! But also noted that the new documentation covers all of these things - and more.

There are workarounds and tools, though! Post back if you need some more info on that.