PDA

View Full Version : What is the best image format for textures?



lucidmm
11-26-2002, 10:15 AM
Are there any good references for image formats?

Thanks for the help.

Nutty
11-26-2002, 11:07 AM
If you're not bothered about space use .TGA's

. They're lossless. So ideal for storing normal maps.
. They support alpha channels.
. They're bloody easy to decode. I have some code on my site in some of my demos that will do it. non-compressed and RLE, 24 and 32bit.
http://opengl.nutty.org/

Else try Jpegs, but not for normal maps, cos the artifacting makes normal maps look crap.

You could try PNG, but not all PNG supporting programs support PNG alpha. i.e. Photoshop 6. They're also lossless.

Nutty

jra101
11-26-2002, 11:11 AM
Try the DDS format. It can store 1D, 2D, 3D, and cubemap textures, with their mipmaps, in a single file.

Another nice feature is support for the DXTC compression format which is supported natively by the hardware so you won't need to be uncompress it before sending it to the video card.

V-man
11-26-2002, 11:41 AM
Are there libraries out there that support DDS?

NOt including the Direct utility package.

V-man

jra101
11-26-2002, 11:43 AM
Try the DDS loader I wrote:
http://cvs1.nvidia.com/OpenGL/include/shared/nv_dds.h
http://cvs1.nvidia.com/OpenGL/src/shared/nv_dds.cpp

[This message has been edited by jra101 (edited 11-26-2002).]

Humus
11-26-2002, 02:58 PM
... or grab the Image.cpp file from my framework at http://humus2.campus.luth.se/~humus/

jwatte
11-26-2002, 08:02 PM
DDS is the preferred vehicle for textures compressed using S3TC (DXTn). Using this compression will give you a 4x texture fetch rate boost compared to 16-bit textures, at an often acceptable quality loss. DDS files can also store MIP maps pre-calculated, which saves a little CPU when loading (and, if they're compressed, it's almost impossible to generate good MIP maps at load time).

nVIDIA has a Photoshop DDS plugin on their web site, as well as a Max ditto.

To load a DDS, you read the first 512 (or 128? I forget) bytes into a DDSURFACEDESC2 (minus a few header bytes), assert that the compression format is what you expect, get the width/height from the header, and then read the appropriate amount of data from the file after the header. (bytecount = width*height/2) MIP maps are just stored consecutively after that.

Last, both DXTC and DDSURFACEDESC2 and the DDS file format are documented on MSDN and/or in the DirectX 8 SDK, all of which are freely available on Microsoft's web site.

Diapolo
11-27-2002, 02:13 AM
Im using the DDS format, too (currently my loading function only supports DXT1, DXT3 and DXT5 compressed textures with or without mipmaps).
I really like it http://www.opengl.org/discussion_boards/ubb/smile.gif.

For Normalmaps I use the RAW-Image format.
It has got not header, only the data, but its pretty easy to handle, but only Paint Shop Pro seems to support that format to my knowledge ...

Diapolo

Julien Cayzac
11-27-2002, 02:19 AM
PNG support an arbitrary number of layers, so it can store Cube Maps as well (using 6 layers).
The format also support (though libpng is a bit buggy here) arbitrary channels' depth so it fits perfectly 32-bit channel needs for ng cards...

Julien.

gibber
11-27-2002, 06:25 AM
V-Man: wrote


Are there libraries out there that support DDS?


DevIL supports DDS loading.

http://openil.sourceforge.net/

dorbie
11-27-2002, 09:16 AM
...and they have a cool logo.

Definitely use a library for this. Nobody should be wasting time writing their own file loaders without good reason. I'd recommend PNG files personally, they include lossless compression, support alpha and luminance alpha formats, are supported in many packages and can be viewed casually in applications like web browsers and support gamma information making platform of creation a non issue. You can also get libpng straight from the horses mouth if you care.

ehart
11-27-2002, 11:12 AM
I like PNG's, but I have really found a lot of nice features in TIFF's. They offer a lot more flexibility then PNG's and they can support deflate compression like PNG's too.

The only problem is that most of the nice features aren't supported in art programs. (32-bit float images, volume images, etc)

-Evan

Julien Cayzac
11-27-2002, 12:50 PM
Originally posted by ehart:
The only problem is that most of the nice features aren't supported in art programs. (32-bit float images, volume images, etc)


FilmGimp is a 32-bit per channel enabled version of Gimp. Maybe it support 32-bit float TIFFs, I'm not sure.

Julien.

zed
11-27-2002, 06:29 PM
i made an greyscale image the other day where is each pixel is a difference from its neighbouring pixel (basically gives u high (difference) resolution with minimum memory)
anyways has this been done before?
ie did i waste my time writing the code when an already existing image format exists already ( http://www.opengl.org/discussion_boards/ubb/smile.gif) most likely of better quality.
and if so whats the nme of this image format?
ta

jwatte
11-28-2002, 07:42 AM
PNG uses neighboring difference as one of the possible filters that you can use before actually compressing the image; this will lead to better compression ratio for certain classes of images.

The idea (coding deltas instead of absolutes) is fairly old (and it's been used for audio, too) but I can't think of any popular format that actually uses it as the main image coding format these days.

Oh, speaking about grayscale images: the .DDS plug-in for Photoshop (from nVIDIAs site) won't let you save a grayscale image; it can only save various RGB images, plus paletted; and evenso, it doesn't accept an indexed input image. I knew there was a reason for good-old TGA to stick around :-)