Review: maketx --alpha1-detect#153
Conversation
|
Also note that I put the test for alpha=1 before the "is it monochrome" test. So it will correctly collapse CCC1 textures to C, if you know what I mean, whereas previously CCC1 textures would not only keep the pointless alpha, they also would fail to recognize the texture as monochrome (except for the very rare case of C==1). |
There was a problem hiding this comment.
I like the refactor of this loop, much cleaner. Are there any issues with src.getpixel if the src image is null or doesnt have any pixels? (what does getpixel do?)
There was a problem hiding this comment.
src is a ref, not a pointer, so it can't be null. I'll put in a check to immediately return 'true' if there are no valid pixels at all.
|
Looks good to me. I'm fine with this name (maketx --alpha1-detect) or any other one. |
|
LGTM +1 for Solomon's suggestion of |
…es had designated alpha channels that were 1.0 for all pixels. Also adds ImageBufAlgo::isConstantChannel() utility.
|
Someday we may want to tag what the original alpha value was in the metadata. (Particularly if we ever introduce an option to drop alphas with a constant 0.0 value). But until we cross that line, I'm all for not adding extra complexity until needed. |
|
At SPI, we checked our shader library and without exception, RGB textures are treated the same as RGBA textures where alpha=1, and I suspect that this is probably a widespread convention. Dropping constant alpha that != 1 seems inherently dangerous, and hard to imagine that the extra logic in the texture system or shaders would be worth the storage savings, for which is surely a rare case of completely constant but non-1.0 alpha. |
maketx --alpha1-detect will omit alpha from textures whose input images had designated alpha channels that were 1.0 for all pixels. Somewhat similar in operation to --monochrome-detect and --constant-detect.
Also adds ImageBufAlgo::isConstantChannel() utility and does some minor cleanup/simplification to isConstantColor.
(Yes, this is because we have textures with pointless alpha=1 everywhere, and it's easier to fix in image-to-texture conversion than it is to actually fix the problem upstream.)