Why do we prefer .png over .jpg for texturing (even if transparent background is not needed)?
tayloranderson2047
Posts: 116
I wonder why for texture maps, .png is always more preferred than .jpg, despite its much larger size? For most textures, I think the transparant background is unnecessary and I personally really can't detect the differences between textures in png vs textures in jpg. I do know that jpg contains less data than png. However, why is that "extra data" important in 3D texturing? Or is it just me who cannot tell the difference between the performance between png and jpg by eyes?
Post edited by tayloranderson2047 on
Comments
You will notice a nasty difference if'/when applying logos, text, etc. to the clothing textures [for example]. Try it in your image editor - see what happens when you merge layers to save out as .jpegs rather than as .png files.
I asked this same question recently and have been told that there is a huge quality difference. But to be honest, in my opinion, the difference is mostly theoretical. Maybe for normal maps, but in general no. And I've been professionally Photoshopping all sort of file formats for twenty years.
It comes down to compression. There are a lot of very highly compressed JPGs used a textures for Daz products, and it just looks bad. JPGs save data because of their compression. If you save at high quality, then it is not so bad, I actually don't mind JPG when saved at high quality. The problem is too many people don't seem to do that for some reason. They don't have to be 100MB TIFF, they just have to stop being so compressed.
Iray is not kind to low quality textures. It gets quite noticeable in normal maps. Any poor compression in a normal is going to show up as a weird sharp edge on what perhaps should be a smooth surface. Compressed textures make Daz Iray look like an old video game.
The higher your render resolution, the more this becomes a problem.
Because JPG is optimised to (at least at higher qualities) encode a photograph* in a way that is not perceptibly different to the human eye.
* It's in the name; JPEG is "Joint Photographic Experts Group"
Both emphases there are important. First up, while they use image formats because the formats are a convenient way to store a large array of data values within a fixed range, texture maps should not actually be thought of as an image; they're data about the surface, that just happens to be presented in a way that is (somewhat) human readable.
Secondly, what the human eye cannot tell a difference between is very different to what a computer cannot tell the difference between. JPEG can get away with throwing away stuff it thinks is noise or compromising some detail when it's just a human looking at it. However, the number of times I've had to help someone debug a problem that turns out to be something like "Oh, the black in the texture file hasn't actually compressed as pure black" is a number I've lost count of.
PNG is a lossless format, so it doesn't have these particular drawbacks.
Also, note that PNG is not always bigger. For files with a small number of colour values - which is not uncommon for texture maps - PNG can actually be smaller. It also has no effect on Iray's memory usage, because all textures are decompressed before being sent to Iray - their original format has no bearing on VRAM usage.
There's only two notable drawbacks of PNG in this case - it's slower to compress in the first place (but that's an "the artist who originally made it problem", not an "end user problem") and sometimes disk usage (and these days drive space is ever cheaper).
It really comes down to a lossless format versus a compressed format. PNG is lossless. less artifacts, cleaner images.
It is true that most humans can't see the difference with a natural eye. But as you zoom in on the pixels you will notice the difference.
So as always with all things in 3D, its the tradeoff of file size for picture quality.
FirstBastion has nailed it. PNG is lossless, i.e. no data is removed from the saved image.
This is especially useful if you want to edit a texture - resaving a jpg is like taking a photocopy of a photocopy; each iteration removes more data.
I find it hard to believe storage space should still be an issue in this day and age. 4tb/8tb HDDs are relatively cheap and ultimately once a texture has been converted to iray's own format when rendering, both a 4k jpg and a 4k png use up the same amount of vram.
As it was already said here, when whatever program opens an image file, the image is decompressed and the format of the saved imagefile becomes irrelevant. When opened the image uses RAM based on the pixel size of the image and color depth (4092x4092x24bit uses 48MB's per image)
Daz Studio sends the image path, not the uncompressed image, to Iray.
Ok, that explains some things I have been wondering about, but the image still has to be uncompressed in the process before it is compressed by the rendering process following the settings specified by the user.
You have never looked at a highly compressed JPEG? Look at the image examples here: https://en.wikipedia.org/wiki/JPEG
Even at the lowest compression the structures that cause these artifact are present in the image and while you might not see them with your own eyes the program code to do maths with the image is not so lucky as to be easily fooled by it. Which can often be seen when JPEG-artifacts are far more prominent in an applied and tendered texture than in the source image.
Do you know if more vram is used if a surface has multiple layered images in the base setting? For example, a tattoo layer above the torso or leg surface? Or does Iray bake them all into one texture when rendering is active? Not sure if it would make sense to flatten all the layers in Photoshop first.
If you go to the surface tab of such surface, you will see that there is a temporary file that that DS creates for such surfaces