Using PNG for a 3D game.

Started by
43 comments, last by Nathan Baum 18 years, 2 months ago
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).
Advertisement
Thanks for the clarification.
OpenEXR
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!
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)
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?

Quote:Original post by Yann L
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.


I don't know... I've never seen a Targa image with any greater than on/off alpha layers... Photoshop CS 2 won't write targas with 32bit RGBA... probably you're thinking of some spinoff of targa that's not directly in line with the targa specification... a 32bit targa has 1 byte for rgb and A is true, but in the specification, the "A" (attribute, btw) is meant to be an on/off. You can even have 16 bit targas with an alpha channel.. where the alpha is defined as on or off by 1 single bit.
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)
Quote:Original post by AAAP
Quote:Original post by Yann L
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.

I don't know... I've never seen a Targa image with any greater than on/off alpha layers... Photoshop CS 2 won't write targas with 32bit RGBA... probably you're thinking of some spinoff of targa that's not directly in line with the targa specification... a 32bit targa has 1 byte for rgb and A is true, but in the specification, the "A" (attribute, btw) is meant to be an on/off. You can even have 16 bit targas with an alpha channel.. where the alpha is defined as on or off by 1 single bit.

Could you tell me the page and the location of that in the spec? I couldn't find anything like what you're saying. Each pixel of a 32-bit TGA file stores one byte for each of the attribute/alpha, red, green and blue channels (8 + 8 + 8 + 8 = 32). And last time I checked, Photoshop had no problem saving an 8-bit alpha channel with a TGA file.

The Truevision TGA File Format Specification (zip/pdf, 50kb)

Regarding the original topic, I use both the PNG and DDS formats. I use DDS when I need to use the features it provides, but I use PNG for virtually everything else. I think the main reason for this is that I primarily use Paint Shop Pro, where the support for DDS is non-existent (the NVIDIA Photoshop plugin only works up to version 7 of PSP).

[Edited by - iNsAn1tY on January 25, 2006 12:52:42 AM]
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Quote:Original post by AAAP
I don't know... I've never seen a Targa image with any greater than on/off alpha layers... Photoshop CS 2 won't write targas with 32bit RGBA... probably you're thinking of some spinoff of targa that's not directly in line with the targa specification... a 32bit targa has 1 byte for rgb and A is true, but in the specification, the "A" (attribute, btw) is meant to be an on/off. You can even have 16 bit targas with an alpha channel.. where the alpha is defined as on or off by 1 single bit.

I think you're confusing the TGA format with GIF, which has indeed only a boolean alpha channel (or better, a transparent colour). TGA has not. In fact, 32bit TGAs (A8B8G8R8) are very common in graphics programming as an intermediate format. Photoshop has no problems writing 32bit TGA, and neither have Gimp, 3DSMax, Maya, and pretty much every other application that can read or write TGAs.

In the very first versions of the format, there was a way to specify the number of alpha bits in the attribute layer: bit0 - 3 of the last header byte. So you could have anything from 0 to 15 bits for the alpha channel. This field was later reassigned to another use, so the number of alpha bits is now deduced from the pixel depth field. A pixel depth of 32 means the common A8B8G8R8 format.

Later on, when TGA was extended with additional (optional) footers, support for things like premultiplied alpha was added (see field 24 of the specs).

I stand behind DDS format. There was a recent thread about it I can write some hilights of it here:

pros:

- D3D native format, fast load, supports compressed and uncompressed textures
- Supports formats such as A8R8G8B8, A1R5G5B5, DXT-compression and many others
- Mipmaps (instead of generating them on fly they can be precalculated with better algorithms and stored on disk too)
- Compressed textures take practically same amount of space on disk than on graphics adapters memory.
- 4:1 or 6:1 lossy compression with DXT. I stress that compressed hi-res textures look usually better than a lower resolution uncompressed texture, and might even take less memory.
- D3D has ready made routines for loading from disk and memory
- NVidia has a plugin for PhotoShop for saving and loading DDS files.

cons (hard to think any):

- perhaps harder to use with OpenGL, but I've seen examples about loading them on OGL
- Old GPU's might not support them (pre-GF3)
In photoshop.. you can't have 8bit alpha in targa. at least not in any that I've ever used, up to and including CS2.

or rather, the attrib byte is 8 bits... but still has on/off functionality.

any targa format with greater than on/off functionality for alpha is an extension of targa, not the base format
|aaap.penopticon.com| My website, including game projects. Collaboration/comments are welcome, please visit :)

This topic is closed to new replies.

Advertisement