Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] General Discussion => Topic started by: romullus on 2014-06-20, 16:26:43

Title: Opacity tex comparison
Post by: romullus on 2014-06-20, 16:26:43
I was making some foliage textures for personal use recently. Saved all maps to png format and begin to construct material. Soon enough i found that my material performs rather poor in therms of speed. Naturally, i blamed opacity map. Tried different tricks, but nothing really helped. So i decided to resave opacity texture to other format and to my surprise, i saw significant improvement. All other formats rendered much quicker... all except png and gif. Later i found out that transparency in those formats is what causing problems. But most interestingly is that gif saved without transparency shows massive improvement in render speed! So from now on, i'll use gif for opacity maps exclusively.
Title: Re: Opacity tex comparison
Post by: Ondra on 2014-06-20, 16:57:53
this is interesting, can you send me this particular scene and the maps so I can run some tests?
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-20, 17:20:21
Done!
Title: Re: Opacity tex comparison
Post by: borisquezadaa on 2014-06-20, 17:51:19
Now that's something interesting!.

Good to know.
Title: Re: Opacity tex comparison
Post by: Siahpoosh on 2014-06-20, 18:06:51
very useful , thank u
Title: Re: Opacity tex comparison
Post by: steyin on 2014-06-20, 18:22:45
Curiouser and curiouser.
Title: Re: Opacity tex comparison
Post by: kahein on 2014-06-20, 18:24:36
thank you for this, very useful
Title: Re: Opacity tex comparison
Post by: Siahpoosh on 2014-06-20, 19:01:10
maybe this is because the informations in those formats , for example you will lost a lot of data in GIF file or u have more data in PNG file (RGB+alpha) somthing like this :
PNG(8bit) > BMP(8bit) > GIF
Title: Re: Opacity tex comparison
Post by: Tweekazoid on 2014-06-20, 21:41:55
if you are interested in further testing, try comparing PNG with and without comprimation, as well as with and without interlacing...
I think the difference why it performs this way for each format is inherently in file format structure itself. Gif uses structure that can be read as 1 pixel at a time and does not relly on decoding other parts of file (with the exception of instructions). So my guess would be that it saves time by reducing the need for buffer. And maybe I am completely wrong
Title: Re: Opacity tex comparison
Post by: Ondra on 2014-06-20, 21:48:20
If max REALLY decodes the original compressed format every time a texture is accessed, then I need to write CoronaMap ASAP. 
Title: Re: Opacity tex comparison
Post by: rampally on 2014-06-21, 03:22:04
If max REALLY decodes the original compressed format every time a texture is accessed, then I need to write CoronaMap ASAP.
that's another great news Keymaster
i was supposed to ask this question today mean while i saw this .. great
Title: Re: Opacity tex comparison
Post by: Juraj on 2014-06-21, 03:42:50
Definitely stirred my curiousity. I don't think there's way to measure this as easily in other renderers, to definitely pinpoint this as 3dsMax fault ?

And if so, I echo Tweekazoi's plea: Compare PNG based on comprimation (with and without), or alpha channel.

With Vray, I use purely .png for some sort of stuff(like foliage :- D), usually without comprimation, although over the time, I can't really remember if all of them are so.
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 11:07:32
I don't know what that comprimation is, you talking about, i guess it's compression, right? Anyway, i did some more tests as requested. Everything is saved from photoshop, source file doesn't contain any layers nor alpha channels (gif and png doesn't support alpha channel anyway). Bmp is provided for reference.
Results are quite confusing, at least for me:
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-21, 11:45:54
I never ever used opacity from alpha. Always from an 8bit bitmap without alpha channel, so that's why i probably never ran into this issue.

I think that results of those tests are not confusing at all. They are actually quite simple to figure out. Best way seems  to be using 8bit opacity maps without any alpha channel.
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 11:48:16
Rawalanche, all these maps are 8 bits without alpha channel.
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-21, 12:00:15
Rawalanche, all these maps are 8 bits without alpha channel.

Then what's that transparency off/on? O_o
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 12:47:19
It's an option in photoshop "save as..." or "save for web..." dialog. But as i stated earlier my source file don't have alpha channels.
I can give you two gif files. One is saved with transparency "on", other with "off". Both have very similar file size and are indistinguishable in ps, but gives very different results when used as opacity maps.
Title: Re: Opacity tex comparison
Post by: Ondra on 2014-06-21, 12:52:51
Can you test it also with vray/scanline/mental ray?
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 13:01:48
scanline/mr - yes, i'll do it later, but i don't have vray.
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-21, 13:14:01
Oh, no, that IS alpha i believe.

The only thing is that Photoshop interprets it as transparency for some formats. Simply because it's easier to explain to non technical users that something is transparent, than that is has an alpha channel they may never heard about.

Here's for example what you get when you save PNG out of max:
(http://i.imgur.com/hMtB8eM.png)

So, everything actually makes sense. Opacity is very, very expensive calculation. It does not just calculate some effect of a material. It calculates if ray has to evaluate the surface or pass through as if nothing happened. And that often happens more than once in a ray path. So any overhead in this very expensive and very often performed calculation will result in a significant slowdown.

Larger bit depth (16bit) = more data to process
Additional channel instead of standard RGB = more data to process

So it actually makes sense.

I usually use just JPEGs for my opacity maps. There i am sure it can not carry high bit depth nor it can carry any sort of alpha/transparency channel. That's probably why i never ran into any problems.
Title: Re: Opacity tex comparison
Post by: Siahpoosh on 2014-06-21, 14:28:23
If max REALLY decodes the original compressed format every time a texture is accessed, then I need to write CoronaMap ASAP.
+ for CoronaMap

Edit : i think this is why Arnold created .tx format for textures :

(http://i.imgur.com/bzFEJdt.jpg)

https://support.solidangle.com/display/AFMUG/Textures
Title: Re: Opacity tex comparison
Post by: Juraj on 2014-06-21, 14:28:54
I was asking about the above chart only as well. Sorry if my word for compression was confusing, I don't know why I stuck with it.

Basically, 8bit (per channel, so RGB24) with/without Alpha channel and 16bit(RGB48) with and without Alpha channel.
And those, with and without compression. But you already proved compression doesn't matter. Good to know. So it all seems to be about bitdepth and alpha channel

I guess we're talking purely about opacity slot right now right ? If so I use 8bit/without alpha, but I still keep the diffuse one as 8bit with alpha (might be pure bullshit, but even if that alpha isn't used, I've noticed better result in Vray? )

Maybe I should give it a try and replicate in Vray.
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 16:11:34
The results of this test is geting ridiculous. I don't have much technical knowledge nor my english is good enough to feel comfortable in such discussion, so i'll leave you with plain numbers. Just a little explanation: i used 2 gif images as opacity map, both saved in photoshop via "save as..." dialog. One of them has transparency enabled, other hasn't. All materials are simple lambertian mats with only map in opacity slot (cutout in case of MR).

p.s. this is not comparison between renderers  in terms of speed!!!
Title: Re: Opacity tex comparison
Post by: lacilaci on 2014-06-21, 17:07:32
You guys use unfiltered maps for opacity right? Or doesn't filtering play any role in this?
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-21, 20:04:00
Filtering of opacity maps is disabled in Corona by default.
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-22, 21:01:45
To add to a confusion even more, i found that pngs saved in PS via "save as.." dialog, have negative impact on render speed, when used as normal maps too. It's not so huge as in case of opacity maps, but quite significant. Diffuse maps seems is not affected by that plague.

Definitely there's something fishy going on between photoshop and 3ds max. Don't know how you guys, but from now i'll try to stay away from pngs as much as possible :/ Tiff is much safer option, i think.
Title: Re: Opacity tex comparison
Post by: rafpug on 2014-06-23, 00:39:04
Bravo Romulus

This test and "interesting"

Regard
Raf
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-23, 22:01:34
Looks like Rawalanche was right, it is alpha channel. Still, i don't know why 3ds max treats files, that don't have transparency info in it, like that.
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-23, 22:04:39
Hard to tell... 3ds Max does a lot of things in a weird fashion.

It would be interesting to test all the different file formats in 8bit depth and without alpha channel. Just to be sure there's no performance gain or loss aside from additional channels or extended bit depth :)

Maybe even test formats which can store just monochromatic data (gifs for example).
Title: Re: Opacity tex comparison
Post by: Tanakov on 2014-06-24, 09:43:10
Thanks this helps a lot, I will now focus on making JPEG's instead of PNG's
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-25, 11:14:33
Ok, here's my latest findings.

What's influencing render time:

bit depth - has no impact
image compression - has no impact
additional layers and layer compression - has no impact
channels - does big impact:
  RGB - normal render time
  RGBA - time penalty
  grayscale, indexed colours - huge bonus

All tests was done in Corona, with tiff file format in opacity map. I may do further tests with MR and/or scanline later.
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-25, 11:19:26
I am actually curious if this is just behavior of TIF, or other file formats as well :) Max does not use one universal plugin to handle image formats. Instead, it has different plugins for different formats of varying quality.

So i would first make sure if this is general behavior, or only TIF format related behavior :)
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-25, 11:45:32
Yes, it's translates to other formats that support alpha channel and/or single channel options.
Title: Re: Opacity tex comparison
Post by: Ondra on 2014-06-25, 12:13:55
ok, I dont have time to investigate this right now, maybe in 2 weeks ;)
Title: Re: Opacity tex comparison
Post by: Ludvik Koutny on 2014-06-25, 12:52:42
I see...

Anyway...  thanks a lot for these tests. I know very well that objective testing takes a lot of patience and time. So not many people take their time to systematically test something, but almost everytime someone does, they discover something either very useful, or some severe bug, which when removed, speeds up or improves quality of Corona a lot :)
Title: Re: Opacity tex comparison
Post by: romullus on 2014-06-25, 14:10:30
That's interesting, i found that it's related to filtering. If i set texmap filtering to "all" - difference in render time between RGB, RGBA and monochrome, completely disappears.

One additional finding is that standart material's opacity map isn't affected by texmap filtering in Corona settings. I'll report that as a bug.
Title: Re: Opacity tex comparison
Post by: snakebox on 2014-10-28, 05:56:43
Sorry for reviving this topic, but I haven't seen any changelogs for some of things being fixed?  And I am curious of all this is the same scenario when using .tga files compared to gif/png ?

Thanks guys! interesting find for sure.