New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Premultiply by default on png #1217
Conversation
I'm certainly glad this can be changed. I understand the panic that sets in when people see images with the halo around it. I find it interesting that Alpha Channels have increasingly become similar to Gamma workflow in that the source and target must be considered carefully. This is likely the result of digital artists using a wider range of programs than they did in the past; where in those days they primarily stayed within the graphical environment of one application where the type of math pre-applied to RGBA channels never changed. Perhaps the oddest thing is that using premultiplied images can force a user to later remove the color matting from the color channels (i.e. unpremultiply them) to get back at cleaner color channels (because the RGB channels have been inadvertently altered by the act of premultiplying their values with the alpha channel. Whether they can do this will depend on the program they use and the options available to them. Fortunately, some programs are being taught how to recognize whether images are straight or premultiplied out of the gate (upon import). At a guess I'd say the image is analyzed for sharp drop offs (hard edges) in the color channels and where predominantly found are interpreted as Alpha Straight? I've always found Alpha Channels to be fascinating (and powerful) but I had no idea just how fascinating they were. |
LGTM Thank you @turtleTooth ! @RodneyBaker In MotionBlurFxIwa, I implemented the procedure for judging whether the source image is premultiplied or straight alpha here. |
@shun-iwasawa said:
Very interesting.I think I actually understood that! Thank you for the information and I look forward to trying out MotionBlurFXIwa! Added: I conducted a small test with two images rendered out of another program (one premultiplied and one straight) and the results were interesting but I haven't quite got to a conclusion. If I import an image into the xsheet that is already premultiplied and OpenToonz is set to premultiply it appears that an extra multiplication is conducted that creates a slightly dark/sharp line around the image. Whereas, the unpremultiplied image is premultiplied upon import and has a soft edge (the ideal edge in most cases I would think). My first impression is that something isn't quite right here but I'm not exactly sure what it is. I think the default setting is going to cause some confusion because the assumption was that users would mostly be importing premultiplied images. However, if they are straight then they look correct but if premultiplied they gain another premultiplication which causes the result not to be correct. This is easily corrected either way (by turning the premultiply setting on or off in the Level Settings) but I am finding the results curious. I'll see if I an share my results in a way that others will understand. As errors go... I see where the black border is preferrable to the white halo so the new default setting of premultiplying for PNGs would appear to be the better of the two but we may need to look again to make sure a second pass of premultiplication isn't taking an already 'correct' image and adding the dark border. That wouldn't be ideal. I need to test with some images saved out of Photoshop, After Effects etc. |
I'm going to go out on a limb and suggest something isn't quite right in the processing of premultiplied PNGs. Assumption: OpenToonz will render out images with premultiplied alphas. Try this test: Added: You'll likely have to add a blur via Schematic Blur node in order to set up the test properly for observing any halo around the text. I set the blur to 2 or 3. Import/Load that PNG into the xsheet and then Right Click on that frame/level in the xsheet to select Level Settings where we will toggle on/off the "premultiply" setting. My assumpion is that the alpha channel is being multiplied twice but I may be wrong in this. Hopefully I'm right as this might be an esay fix. Of note (as mentioned in my post above) I tested with a 'straight' alpha rendered in another program and the image looks correct with "premultiply" on in Level Settings and wrong with it off (the image has the dreaded white halo. So, OT is handing "straight" alphas with PNG images correctly by default. So that much appears to be correct. This is with the latest nightly build as of 2017-05-26 08:10:40 UTC. |
@RodneyBaker Thank you for pointing the problem out ! The problem is that OpenToonz renders the PNG image with premultiplied alpha. According to the PNG Specification , it says that PNG should be straight-alpha in normal.
|
I posted a new issue. |
Thanks for the quick response and posting of the issue. :) For completeness sake... I also tested TGA. |
PNG supports straight alpha only whereas TIFF and TGA also support premultiplied alpha. In Japanese animation industry they are handling tons of TGA files as it is standard format for RETAS PaintMan. |
#794
This turns on premultiply by default for png files.