PNGs and alpha layers - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Designer's Studio (/forum-6.html)
+--- Thread: PNGs and alpha layers (/thread-6993.html)
PNGs and alpha layers - KidTsunami - Jun 20, 2003 12:04 PM
I'm writing a 2D openGL engine using pngs and testing it I've used Carlos's png textures that he just put up. But I realize they don't have an alpha layer. I can't seem to figure out how to use photoshop to make pngs (or any image for that matter) with an alpha layer. Any guidance would be much appreciated.
PNGs and alpha layers - DoG - Jun 20, 2003 12:22 PM
Quote:Originally posted by KidTsunami
PNGs have similarly to GIF a transparent color, which I don't think is too easy to exploit in OpenGL. If NSImage or quickdraw can draw it correctly, you can use it as a texture. If not, I suggest you try converting them to TIFF images, which I know handle alphas well, and are well supported, too.
PNGs and alpha layers - Frank C. - Jun 20, 2003 12:38 PM
Do your self a favour and download the SuperPNG plugin: http://www.fnordware.com/superpng/ (it's free).
Alpha's in newer versions of Photoshop can be created two ways:
The "old" way is to create go to the channel palette and create new channel, and draw in it - the first channel after the R, G & B channels is used as the alpha.
The "new" way is to create your art on a new layer (instead of the "background" layer) and just leave some parts transparent.
I prefer the old method myself, as there are times when you may want to reverse the alpha, or make certain bits invisible without destroying the image data, or pre-multiply the image.
DoooG: PNG's can contain a full 8 bits of alpha, just like TIFF (and compress without resorting to proprietary algorithms like LZW). You can also use 1bit alpha's in OpenGL just like any other alpha - it's your loading code that does the work, OGL doesn't really care where the alpha comes from or how it looks. If you want an OGL texture to "behave" like it has a 1bit alpha, just use alphatesting rather than blending.
PNGs and alpha layers - KidTsunami - Jun 20, 2003 12:41 PM
But Frank C. using Photoshop, I can't save with the alpha layer. Would the superpng plug in solve that?
Also, if possible is there any other programs that I can make pngs with alpha layers easily? I'm just trying to create some test art assets quickly.
PNGs and alpha layers - skyhawk - Jun 20, 2003 12:56 PM
graphic converter can also add alpha layers to images.
PNGs and alpha layers - DoG - Jun 20, 2003 01:26 PM
Quote:Originally posted by Frank C.
The problem is getting the PNG to render into a buffer which can be passed to OpenGL. Assuming QuickTime or NSImage doing this, it has to be checked into what pixel format they can render. I know QT does it into BGRA with 8 bits per channel. So yes, the loading code does the work, and if you don't want to write a custom PNG loader, QT is the obvious choice.
PNGs and alpha layers - Jake - Jun 20, 2003 01:34 PM
Quote:Originally posted by KidTsunami
I was having similar problems in PS7, this is what I did to fix it. Click the "Save as Copy" button in the save dialog, then the Alpha Layer check box should be enabled.
PNGs and alpha layers - KenD - Jun 20, 2003 03:08 PM
I just save images with alpha as TIFF. Works great. I haven't had any good success with PNG and alpha channels.
PNGs and alpha layers - Frank C. - Jun 20, 2003 10:11 PM
Quote:Originally posted by KidTsunamiYes (the built-in PNG support is pretty pathetic)
Quote:Originally posted by DoooG
PNGLib is best for loading PNG files: http://homepages.cwi.nl/~jack/macsoftware.html (it has ordering functions built in if you need them) but QuickTime should handle them just fine, and once you have the bytes you can coerce them into whatever format ya like. Here's an OpenGL specific PNG loader as an example: http://www.wyatt100.freeserve.co.uk/download.htm
PNGs and alpha layers - KidTsunami - Jun 21, 2003 01:11 AM
Well, I really don't have a problem I guess loading pngs, I'm able to load both carlos's textures and a jpg I had that I brought into photoshop, added an alpha layer, then saved them with super png. But if I change anything but the alpha layer, and save them using super png, they show up as white blocks the size of the actual texture. Does this have to do with the order the bits are in?
This is starting to give me a crucial headache
Mind you I'm saying they show up as white blocks when i load them into my game.
PNGs and alpha layers - KidTsunami - Jun 21, 2003 01:15 AM
I just don't know, i've been having many problems using these PNGs, are you sure I can't just use jpegs as sprites and use them in a way that the background doesn't show, just the sprite. I know they just have RGB bits but there has to be some sort of easier way to deal with regular sprites and openGL...?
PNGs and alpha layers - Carlos Camacho - Jun 21, 2003 08:32 AM
>Do your self a favour and download the SuperPNG plugin
I can'T agree more. I use SuperPNG to save those textures. (Speaking of which, I haven't gotten any feedback on them!) I don't expect everyone to keep them in PNG, so use whatever format is best for your project. I picked PNG for file savings.
PNGs and alpha layers - Sta7ic - Jun 21, 2003 11:15 AM
I'm not really sure what this thread is about anymore...
PNGs -- Portable Network Graphics -- are images that use a free compression routine, and happily support 32 bit RGBA formats. The artist working on a project with me is using that format, and there've been no problems. As Frank said and DoooooG agreed, that format's R:8 G:8 B:8 A:8.
The "baseline" source for loading PNGs, to my knowledge, is LibPNG and ZLib, both available from http://www.libpng.org and generally free. They also have a page with libraries that wrap the libpng/zlib functions for various reasons; I've found that glpng works great if you remember to set the orientation flag (don't ask). The libpng and zlib code is straight C through and through; you'd have to been masochistic to rewrite the code completely in Cpp or Cocoa or whatnot.
To make OpenGL work with these things, you need to have your loader pick up the alpha channel, the texture format in GL_RGBA_32 (or some such w/ alpha), enable alpha blending, and then remember to draw the transparent objects LAST (the Red Book also says to turn off z-buffer writing).
Email sta7ic at neonshadow dot net if you want some source to look through.
Good luck w/ your graphic problems.