• Advertisement
Sign in to follow this  

Using PNG for a 3D game.

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to decided on a primary image format that I can use for a 3D video game that I am developing. I've done some research and I'm leaning towards the PNG format since it is free of any patents, has lossless compression, and has a library for the format. Anyone have any suggestions or comments?

Share this post


Link to post
Share on other sites
Advertisement
with all the pluses with PNG, it also means having to fuss with graphic compression. unless you're totally hellbent on lots of little graphics, or relatively few high-res / photo realism graphics, probably settle for a more moderate format. Well, thats if you had to pick just one... which of course you dont

Share this post


Link to post
Share on other sites
.PNG is the only format I ever use anymore for anything except photographs, which are usually .JPG (unless I'm looking for lossless, anyway).

As far as AAAP's post about "fussing with graphics compression", there are many free libraries out there for loading .PNGs, so you don't have to write them yourself (SDL_image for OpenGL, or the built in DirectX functions are a few).

Share this post


Link to post
Share on other sites
well ok, fair enough. I guess I havn't mentioned in this forum that I'm very much relentlessly opposed to using SDL in any project :o

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
well ok, fair enough. I guess I havn't mentioned in this forum that I'm very much relentlessly opposed to using SDL in any project :o


Why?

And yes, PNG is just fine. It's a very solid format that also stores alpha information (RGBA)

here are two methods
SDL + SDL_Image
glpng

Share this post


Link to post
Share on other sites
Usually, you want a format that allows artists to control the texture in quite some detail (compression, bit depth, MIP maps, etc) for your on-disk delivery format. PNG doesn't do so well there.

Similarly, you want as rich as possible a format for the source, so that you can go back and tweak certain layers of a texture. PNG is hopeless there, as it collapses everything to a single raster.

I use DDS for the delivery format, and PSD for the source format (because my graphics tool is Photoshop). DDS is not patent encumbered, is well described, and supports niceties like 3D textures, cube maps, built-in MIP maps, DXT compression, 16-bit textures, 32-bit textures, float textures, etc. It's very easy to parse, too, and the data is not, actually, DirectX specific.

Share this post


Link to post
Share on other sites
to backup what hplus0603 said, png is designed mainly for webpages which it does well at, its not designed for games.the best for games is dds

Share this post


Link to post
Share on other sites
I don't think PNG is entirely unsuitable for games... especially 2D games (maybe not for texturing 3D models though, not sure). Think about it:

pros:
-lossless
-Indexed or pixmapped color(depending on your needs)
-Very flexible color index system compared with others
-Better alpha channel than some other formats (who work often with a on/off style alpha channel, whereas PNG has 8 bits of alpha per pixel if enabled)

cons:
-pixmapped PNGs can be very large
-loading a PNG image requires decompressing compressed data blocks (MAY result in a slight performance hit)

look at the alternatives though:
GIF and similar spec:
-most other indexed formats have a fixed number of color indexes, whereas with PNG you can have as little as you need

for pixmapped images:
Targa have worse alpha channel and similar RLE / index color issues as GIF.
JPEG not lossless!

I mean overall, PNG isn't really a bad choice of format, especially because of the powerful alpha channel, it's not really "only" good for web use. The downside is that it CAN be relatively difficult (everything is relative) to implement if you don't want to contaminate your code with gpl'd code

Share this post


Link to post
Share on other sites
If you decide to go with PNG, I *strongly* recommend Corona as image loader library.
It's open source, independent of SDL, so easy to use and supports also other formats like JPG, BMP and TGA.

Lutz

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
Targa have worse alpha channel and similar RLE / index color issues as GIF.

What's the problem with the alpha channel in TGAs ?

Quote:
Original post by AAAP
The downside is that it CAN be relatively difficult (everything is relative) to implement if you don't want to contaminate your code with gpl'd code

libpng: no GPL/LGPL contamination, no SDL dependencies. Problem solved.

Share this post


Link to post
Share on other sites
In targa, alpha is boolean, it's not "wrong" per se (i use targa), but it's not as powerful as that found in PNG

Share this post


Link to post
Share on other sites
I would say you are wrong. IIRC TGA transparency is (or at least can be) 8-bits as other (R, G and B) components.

Just my 2 cents...

Share this post


Link to post
Share on other sites
I back the recommendation for DDS. Historically, DDS stands for "DirectDraw Surface," because the format was just a dump of one or more DirectDraw surfaces; transferring to and from a DDS file from a surface was trivial. DirectDraw surfaces are now Direct3D surfaces, but the principle remains the same - it means that anything you can store in a D3D surface (including indexed/paletted data) can be stored in a DDS file.

The DXT compression can also be a really big win, too, because you generally don't need to decompress it on load (modern hardware supports it directly).

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
In targa, alpha is boolean, it's not "wrong" per se (i use targa), but it's not as powerful as that found in PNG

Alpha is not boolean in Targas. It is usually 8 bit (ie. standard 32bit RGBA data), but the format can even support a 32bit alpha channel (128 bit RGBA). Although the latter is usually not supported by common graphics applications.

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
-pixmapped PNGs can be very large


I have to ask what was meant by this as I'm genuinely
curious. Surely an uncompressed PNG will be exactly the
same size as any other uncompressed format in memory?

Share this post


Link to post
Share on other sites
Quote:
Original post by jvkao
I have to ask what was meant by this as I'm genuinely
curious. Surely an uncompressed PNG will be exactly the
same size as any other uncompressed format in memory?


I think he's talking about png in lossless compressed form which can be quite
large compared to an equivalent compression format (like jpeg).
Well I guess it all depends on what medium you're redistributing on,
and how many texture you can fit on that medium.

If you're tight then you should select a lossy format.
(and jpeg in highest quality mode is almost lossless but still a fraction of the size of a lossless png).

Share this post


Link to post
Share on other sites
well basically im just saying.. you should do your research and weigh the pros n cons to choose your main formats. thats the most important thing!

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
well ok, fair enough. I guess I haven't mentioned in this forum that I'm very much relentlessly opposed to using SDL in any project :o



Yeah, me too. Not sure why - maybe 'cos opengl and directx are used throughout the industry (game and film etc) and SDL is not. I mean, have you ever applied for a job that required SDL or halfway through the interview the guy says "are you proficient with the use of SDL"? So why waste time with SDL?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement