Bad texture quality

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

ejik wrote:I have done like all you guys said, i.e. forced 32bit textures and modified texture to be POT (I made it 512x512 JPG) and it seems to be better.
well, also jpg can be the problem here, because jpg is a lossy format, because of the compression !!!
bmp has the best quality, because it's raw data... ;)

e.g. this images (jpg) has a compression factor of 1 (bmp has no compression so it would be an even more better quality):
Image

and this is the same image with a higher comp. factor (I think it was around 17):
Image

both images are scaled by 2 to show the results better... ;)
and all images are created from the same BMP image !!!

EDIT: and this is also the same image with highest compression (99):
Image
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

Well, jpg is meant as a photo image format not pixel art (as your rectangles are) so your examples are not entirely accurate.
For textures, I think jpg works really well.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Eigen wrote:Well, jpg is meant as a photo image format not pixel art (as your rectangles are) so your examples are not entirely accurate.
For textures, I think jpg works really well.
but that doesn't change the fact that you loose quality with jpg compression:

this is the faerie2.bmp from the sdk (scaled by 2 for visualisation):

as jpg with compression level 1 (nearly original quality):
Image

as jpg with compression level 20:
Image

as jpg with compression level 99:
Image
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

oh, and another thing:
even most (all?) graphic progs (like PaintShopPro in my case) call it compression it isn't a compression like (e.g.) zip, rar, etc. !!!
jpg stores the data calculated from pixels close to each other and creates so a new data that is corresponding to the original but not exactly as the same data, so it can't decompress it to the original data (so compression might be the wrong term with jpg)... ;)

and just if you want to learn more about jpg: http://en.wikipedia.org/wiki/JPEG
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
CuteAlien
Admin
Posts: 9732
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Well, Irrlicht won't magically improve a bad quality image. But it also shouldn't display jpg worse than they are shown in other image tools (at least as long as they are POT).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CodyCer0
Posts: 41
Joined: Mon Dec 08, 2008 3:07 am

Post by CodyCer0 »

Acki wrote:oh, and another thing:
even most (all?) graphic progs (like PaintShopPro in my case) call it compression it isn't a compression like (e.g.) zip, rar, etc. !!!
jpg stores the data calculated from pixels close to each other and creates so a new data that is corresponding to the original but not exactly as the same data, so it can't decompress it to the original data (so compression might be the wrong term with jpg)... ;)

and just if you want to learn more about jpg: http://en.wikipedia.org/wiki/JPEG
I could be wrong, but if thats the case, it makes me think of it stretching one pixels color across some others nearby it and it kinda makes all those squares seem reasonable to be their.

Its kinda like one pixel has fill

0xf9090 (no idea what that would be, just a random thing I typed that I recognize as what I usually see in flash when dynamically defining colors)

and others around it are:

0xf4920

0xf8347

0x8ffff

etc...

And then it takes the color of one of those (I couldn't name which) and set the colors of the others round it to its color setting. Maybe less variety of colors in the image make the filesize smaller too. So if you have the same color being stretched around others around it. It would logicly take down filesize

Only reason I'm not sure is because I don't know if filesize depends on variety of colors used.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

CuteAlien wrote:Well, Irrlicht won't magically improve a bad quality image. But it also shouldn't display jpg worse than they are shown in other image tools (at least as long as they are POT).
well, it's like a TV screen, the closer you get to the screen the more you see the pixels and if you're close enough you can identify each color a pixel is build of, and if you go farther away the picture gets sharper (for your eyes/brain)...
so if you get closer to a node with bad quality texture you'll see the bad quality better than from a distance... ;)
and it also depends on the node's size (of course), a large node is like you're close to a small node and vice versa... ;)

I often like to compare jpg and mp3, because mp3 does something similar, but for sound...
mainly it removes details that (usually) no one can hear/recognise, so you wont hear a difference to the original, but there is a difference (quality loss) and depending on the encoding settings you get better quality but bigger files or bad quality and smaller files... ;)


@CodyCer0: well, it's not that easy, but it goes in the right direction... ;)
Wikipedia wrote:JPEG codec example

Although a JPEG file can be encoded in various ways, most commonly it is done with JFIF encoding. The encoding process consists of several steps:

1. The representation of the colors in the image is converted from RGB to YCbCr, consisting of one luma component (Y), representing brightness, and two chroma components, (Cb and Cr), representing color. This step is sometimes skipped.
2. The resolution of the chroma data is reduced, usually by a factor of 2. This reflects the fact that the eye is less sensitive to fine color details than to fine brightness details.
3. The image is split into blocks of 8×8 pixels, and for each block, each of the Y, Cb, and Cr data undergoes a discrete cosine transform (DCT). A DCT is similar to a Fourier transform in the sense that it produces a kind of spatial frequency spectrum.
4. The amplitudes of the frequency components are quantized. Human vision is much more sensitive to small variations in color or brightness over large areas than to the strength of high-frequency brightness variations. Therefore, the magnitudes of the high-frequency components are stored with a lower accuracy than the low-frequency components. The quality setting of the encoder (for example 50 or 95 on a scale of 0–100 in the Independent JPEG Group's library[4]) affects to what extent the resolution of each frequency component is reduced. If an excessively low quality setting is used, the high-frequency components are discarded altogether.
5. The resulting data for all 8×8 blocks is further compressed with a loss-less algorithm, a variant of Huffman encoding.

The decoding process reverses these steps. In the remainder of this section, the encoding and decoding processes are described in more detail.
so in my opinion bmp is the best format if you want good quality, presupposed you don't need an alpha channel !!!
the file size doesn't matter here, because you can zip the files...
and remember that the same image uses the same RAM, regardless if it's a jpg or bmp, it only makes a difference on disc space... ;)

but I also must admit that I'm using jpg, too (most of the time)... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Cloudef
Posts: 123
Joined: Wed Dec 03, 2008 9:02 pm
Location: Finland

Post by Cloudef »

For me BMP is only good if i want to get something really accurate or keep the image in raw format. But i usually keep the project files rather than BMP's which can store all data (layers, alpha etc..) :roll:
But yeah i usually use PNG's for everything accurate and TGA's and DDS's for texture. JPG is not useless either, it can maintain good speed while still having acceptable quality.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Cloudef wrote:For me BMP is only good if i want to get something really accurate or keep the image in raw format. But i usually keep the project files rather than BMP's which can store all data (layers, alpha etc..) :roll:
But yeah i usually use PNG's for everything accurate and TGA's and DDS's for texture. JPG is not useless either, it can maintain good speed while still having acceptable quality.
yup, I agree... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply