Reputation: 1137
I want to know how to calculate how much video memory or memory cost by a texture. for example, how much video memory cost by TGA or DDS or PNG or JPEG. Are the same?
If there are the same, why PVRTC cost less video memory than PNG in IOS.
I know this is such a big topic that can fill a book. So does anyone can give some references for this topic after brief introduce. Thanks in advance.
Upvotes: 0
Views: 4538
Reputation: 1055
Just to add to SigTerm's excellent reply: PVRTC will use either 4bpp or 2bpp in both "video" memory and in the stored file (unless something like zlib is used to obtain additional file compression.) The iOS GPU knows how to decompress these formats natively.
Formats such PNG and JPG are useful for reducing file data sizes but must be decompressed to, say, 32bpp, in order to be accessible by the GPU. This is necessary because these formats do not allow random access to pixel data, which is essential for texturing.
FWIW, some background information on PVRTC and other texture compression methods can be found here:
Upvotes: 1
Reputation: 26419
TGA or DDS or PNG or JPEG. Are the same?
That's file format. File format has little to do with texture format in video memory.
TGA, PNG and JPEG are generic file formats. When game reads a file, it decompresses file and converts it into internal representation. From those formats, png offers lossless compression, jpeg offers lossy compression, tga is normally uncompressed. I think that only png and tga support transparency.
DDS is somewhat DirectX oriented, because it stores data in one of the texture formats supported by DirectX. May be compressed (lossy), uncompressed, with or without alpha channel.
As far as I know, (at least)DirectX supports two (types of) texture formats - compressed and uncompressed. In addition to that, texture might have mipmaps or might have no mipmaps. OpenGL should support some compressed formats, but I haven't tried to use them in OpenGL, so I'm not quite sure.
width*height*pixel_size
of bytes of video memory (driver may allocate more).width*height*pixel_size*2
bytes of video memory.size*size*pixel_size*6
bytes of data.width*height*depth*pixel_size
bytes of data.Now, here's a list of texture formats for DirectX. Anything that is not DXT is uncompressed, but has different set of channels, and different number of bits per channel. For example, there are several 16bit texture format. DXT formats offer lossy compression, which will produce noticeable ugly artifacts if you apply it to normal maps in your shader. Depending on your data, DXT format can significantly reduce size of texture. Because format is lossy, it is not suitable for normal maps, and for 2d art that's supposed to be masked with alpha-channel.
some references
You can download DirectX sdk, opengl standard, or your platform documentation (if you're developing for something like ios) and start reading.
Upvotes: 2