Sign in to follow this  
dave

Is Transparency with JPG possible?

Recommended Posts

Nik02    4348
No. I recommend PNG or DDS formats, they can handle alpha channels very well. As to which one to use - PNG is good for absolute image quality, while DDS, though lossy, can be decoded on display hardware so that the memory bandwith requirement is lowered considerably.

-Nik

Share this post


Link to post
Share on other sites
alnite    3438
JPG doesn't accurately store color information per pixel. It's a compression. What you see as white is not pure white color RGB(0,0,0) but the values are varied depending on the compression level.

You can achieve transparency with JPG but through masking, not color keying.

Share this post


Link to post
Share on other sites
Pxtl    354
Okay, is there any common lossy standard designed with alphas in mind? Or even better, an N-Channel system, in case you've got other non-colour texturemapping needs? The fact that the choice seems to be either jpg(lossy) or png(alpha, but non-lossy) seems to be missing a meeting of the formats.

I guess a series of monochrome jpgs could be compiled into a single zip... especially if the headers could be merged into a single file... does jpg have optimizations for monochrome images?

Share this post


Link to post
Share on other sites
Samurai Jack    455
Greetings!

Here how it goes: Video cards can not handle JPEGs directly, so they take the same amonunt of VIDEO MEMORY AS A BMP FILE WOULD. If you are using DirectX then definitve take DXT1 for textures and DXT3 or DXT5 for transparent TEXTURES (clouds, windows & stuff). DXT "can" show you the minimum size the TEXTURE will take in your video memory. In case you are using OpenGL try some S3TC compression formats (nVidia SDK site).

If you would be able to load a 10kb 512x512 texture, it would take at least 768KB in Video memory.

Share this post


Link to post
Share on other sites
Pxtl    354
Yes, for video reasons bmp makes sense, but the fact is that more and more content is being served over the net. Ever logged on to a UT server and been bogged down with downloading packages? 90% of the weight of those things is texture data. Cube uses jpeg-based graphics and is a very light download, comparitively.

Any sort of net-served content should be based on lossy textures rather than bogging the connection with pedantic ideology.

Share this post


Link to post
Share on other sites
As far as I know, the JPEG format can handle arbitrary channels and color spaces. It's just that most JPEG routines only have code for reading and writing 8 bit grayscale and 3x8 bit RGB. From looking at the source code for the Independent JPEG Group's JPEG library, I get the impression it is prepared for handling other color channel distributions as well. You need to adapt your code for that, however, and not rely on a precompiled JPEG library, like the D3DXLoadSurfaceFromFile function, for example.

Share this post


Link to post
Share on other sites
Pipo DeClown    804
JPEG isn't evil. It's pretty good, unless you are using less than 100% quality when saving.
PNG is good, but Internet Explorer 6 doesn't support colorkeying with it. (IE6 does support colorkeying with GIF)

I suggest you use Targa for game development.

Share this post


Link to post
Share on other sites
Pxtl    354
Umm, wouldn't that be a 32-bit ping (8r8g8b8a)? And, as I've already noted, lossy compression really is necessary if you're distributing your content online. 4 gig games aren't an option even with high-speed connections. Yes, its a waste of 3d card resources, but by that logic websites that use jpgs are wasting 2d-resources and monitor real-estate.

Share this post


Link to post
Share on other sites
Samurai Jack    455
Pxtl: Nobody said it's an Internet game? And nobody said he is making Unreal Tournament 5. We just don't know. JPEG is good for recording but not for reproductive reasons. If he is just learning DX and he makes projects under 100MB why bother? Maybe the author of this question will post the reason why.

Share this post


Link to post
Share on other sites
Melekor    379
Quote:
Original post by Pipo DeClown
JPEG isn't evil. It's pretty good, unless you are using less than 100% quality when saving.


Actually after around 85% quality with your jpeg, you will notice a massive increase in filesize relative to a negligible increase in quality.

Quote:
Original post by Pipo DeClown
I suggest you use Targa for game development.


Targa is pretty similar to BMP, just a basic format limited pixel formats and with RLE as its only compression option, so I would not recommend that.
Personally I would recommend using PNG and DDS as Nik02 said. Use png for line/vector art, or things that must be lossless, and DDS for the natural textures. This will give you both the best compression and most flexibility with what pixelformat you want. PNG will even support 64 bit floating point pixels if you need them.

If you will use jpg and must have alpha, an option is to store the alpha separately in a png(or other) and recombine them before uploading the texture.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this