Skip to main content
GameDev.net gamedev.net
🔒 Locked

dds vs. jpeg, which is better

Started by QuadMV Oct 16, 2007 at 5:55 PM 10 replies 12k views
Original Post
QuadMV
QuadMV
I've always believed .DDS files were supposed to be better because they're compressed and provide HW support with the compression, right? Therefore, when loaded they don't expand to native size and therefore save space, right? I noticed on disk a jpeg of the exact same file is considerably smaller. Does the jpeg expand when loaded into a texture? I'm trying to create a casual game that will have a small download size, so I'm torn between .dds vs. jpeg. Can someone further support one or the other? Thanks
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
darookie
darookie
JPEGs are compressed on disk and decompressed when loaded into VRAM. You can, however, at the cost of increased loading time have D3DX compress the images to DXT1 at load time.

Note that this will result in poorer texture quality as an already compressed image gets compressed again and in case of S3TC and JPEG both methods are lossy.

Depending on the image content, compressed DDS images might be better (e.g. if you have a lot of crisp edges and artificial motives) or worse than JPEG (for example if your images feature a lot of soft colour gradients).

If you are worried about download size, keep in mind that most installers compress the files anyway and depending on the image content, DDS images can compress quite well.

Hope that helps,
Pat
yahastu
yahastu
Quote:
The DirectDraw Surface (.dds) file format is used to store textures and cubic environment maps, both with and without mipmap levels.
MJP
MJP
.DDS doesn't inherently have compression. It supports many formats that directly correspond to D3D texture formats, of which some are compressed (the DXT formats). These DXT formats also remain compressed when loaded onto a texture surface, unlike JPEG which will be decompressed (unless recompressed by loading it into a DXT format).
Krohm
Krohm
This problem is more a theorical one that something you really have to fight against. Low compression JPG typically introduces only slight color variations. Furthermore, JPGs have been used for years in games so there's strong evidence this article should be taken with salt.

As I have stated multiple times: don't ask what format is better, ask what format is better in your context.
I found the PNG+JPEG combo to be extremely flexible.
Adding DDS and EXR is valuable, but once I have PNG and JPEG, there's very little I cannot do. Then, it's not a point of choosing a format and converting everything to it. You obviously wouldn't encode a alpha texture in JPG. Same considerations apply for color precision, spatial artifacts and such.
Previously "Krohm"
jollyjeffers
jollyjeffers
DDS files are more of a D3D/DD-friendly format that allows for very quick streaming of data straight into the internal memory structures. All other formats require some degree of massaging to get from the external file format to the internal data structures.

Quote:
This problem is more a theorical one that something you really have to fight against. Low compression JPG typically introduces only slight color variations. Furthermore, JPGs have been used for years in games so there's strong evidence this article should be taken with salt.
I don't like to be argumentative, but using JPEG's for texture mapping is simply a case of using the wrong tool for the job. Just because everyone else is doing it wrong doesn't mean you should do it as well [smile] It's just the whole premultiplied alpha hiding under a new name...

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
NegativeGeForce
NegativeGeForce
the only real advantage for a format like dds is the fact you don't have to do any processing to the format after loading the texture. This is more usefully for such games with large amounts of content. Smaller games may benefit more from using only PNG's and uncompressed textures in vram as you can never beat lossless images.

I guess it all really depends on your goal for the game.

1. amount of content
2. target hardware
3. target loading performance
4. target hard disk space/distribution method

large content, balls out = lossless textures full RGBA (impractical)
large content, expensive hardware = low lossy compression
large content, cheap hardware = high lossy compression
medium content, expensive hardware = no compression/low lossy compression
medium content, cheap hardware = low lossy compression
small content, hardware not big deal = lossless

Or you could pregenerate 2 sets of textures or maybe just only load X ammount of mip map chains depending on system specs/graphics level. It all depends on these few things.

And to answer your last question, my casual puzzle game uses lossless png's and uses roughly 24mb of memory at full 32bit modes and 12mb at 16bit modes. It runs on a pci 16mb voodoo 3. For pretty much any casual game you really dont need texture compression. You will get higher quality images, and thats way more important for detailed 2d puzzle games then how much memory your using.
S1CA
S1CA
Quote:
Original post by NegativeGeForce
the only real advantage for a format like dds is the fact you don't have to do any processing to the format after loading the texture.


[I'm assuming when people are talkinhg about DXT compressed flavours of DDS files here]

DXT compressed textures can be used directly in their compressed form by most modern GPUs so the main advantages to using DXT compressed textures instead of using a JPEG and decompressing into an RGB format are performance related:

1) DXTs take up less space in memory so more textures can fit in local video memory (i.e. on the graphics card, local to the GPU so faster to texture from) so there are fewer per-frame texture uploads to local video memory.

2) Related to the above point, less bits used per texel at the GPU end of things means more texels fit in the texture cache so less cache misses.


Quote:
Or you could pregenerate 2 sets of textures or maybe just only load X ammount of mip map chains depending on system specs/graphics level.


Yep, I agree, both good strategies. An alternative is to do the conversion to the most appropriate form during installation so the work is only done once (with the option to re-do it if the user's hardware configuration changes).
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
MasterWorks
MasterWorks
Quote:
Original post by jollyjeffers
I don't like to be argumentative, but using JPEG's for texture mapping is simply a case of using the wrong tool for the job

I can see where you're coming from but I totally disagree coming from a casual games perspective... if download size is a concern then JPEGs are the best way to incorporate large, high detail images. JPEGs from weaker image editors can look bad but on a high quality setting in a program like Photoshop (where you can choose the quality level), it becomes nearly impossible to tell the difference between the JPEG and a lossless format while still taking up only 25% or less of the equivalent disk space. JPEGs also generally look WAY better than a compressed DDS format for every test -I- have ever done. Even for prominent graphics (title screens, menus, etc.) the average user will absolutely not be able to tell the difference between lossless and high-quality JPEG.

I would have been dead meat without JPEGs for my last several projects. I have even needed to use two JPEGs combined at run time to create a texture with an alpha channel, which worked quite well. I would have loved to use a .PNG (which is a great format for sprites and the like) but at 1024x1024 or larger, you're starting to talk about >1MB per file, which wasn't an option. The equivalent JPEG combination weighs in around 300k. I realize that download size is becoming less and less of a concern but even in larger projects there are often a lot of spots where JPEGs can be used. If it takes way less space and looks 99.99% as good, why not?
jollyjeffers
jollyjeffers
Quote:
I totally disagree coming from a casual games perspective...
Ok, fair enough [smile]

Out of curiousity, what 'style' of graphics are your casual games dealing with? Is it traditional 2D graphics, or are you dealing with complex 3D imagery with realistic lighting?

My experience (and I think echoed in Steve Baker's article) is the lighting cases - if you use JPEG files as a source for diffuse maps in low-lighting scenarios it often looks horrific. Truly and utterly horrific. Also, where any sort of perspective or mapping distortion is involved it can really bring the artifacts, even from a good compressor, to the fore in an ugly way.

Have you looked into the JPEG-2000 specs (think thats the right name) - pretty sure they were lossless or had a lossless mode. Could be interesting to see how that compares to lossless PNG compression...

Cheers,
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
MasterWorks
MasterWorks
Quote:
Original post by jollyjeffers
Out of curiousity, what 'style' of graphics are your casual games dealing with? Is it traditional 2D graphics, or are you dealing with complex 3D imagery with realistic lighting?

Most 2D stuff; I was primarily referring to cases where the final pixel colors aren't going to be heavily processed. I don't doubt your comment that certain situations have horrific results. But for things like rectangular/full screen sprites, and skybox textures, you couldn't pay me to use anything except JPEGs. As far as I'm concerned you can build almost any 2D (or 2D with very basic 3D) project without need for anything outside of (.PNG/.JPG) for textures.

The hybrid JPEG with alpha channel was a land texture map for an Earth sphere, (which needs an alpha channel so that only the ocean receives specular highlights) so I know that at least this works for at least some basic 3D applications. I doubt anybody here could tell the difference if I posted screen shots of both the PNG and JPEG versions. Plus, a lot of such texture data (whether optimal or not) has been JPEG'd at some point, either by a digital camera or web server trying to save bandwidth, or just somebody that didn't know better. In these cases saving the lossy data losslessly (as .PNG) is fairly ridiculous and probably is just a waste of disk space.

I'm not trying to overemphasize this as I realize download size is not a primary concern for many people, but I couldn't stand letting this thread slip into the archive without noting that there are SOME very valuable uses for JPEGs. Obviously you want to work with/manipulate some sort of lossless file and only save as JPEG as the final step.

Certain images (even when very large) also compress extremely well with .PNG, so for precise shapes or colors (gradients, etc.) that is a superior solution. You do also have to keep in mind that once loaded into memory, you're still going to pay the price based on the image dimensions and not the size on disk, which somewhat diminishes the value of using JPEGs. Still, when your entire game needs to be only 10-20MB or so, this can be an obvious compromise to make.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.