jeanphi wrote:Is that a requirement from the file format standard or just the way it works in LuxRender?
OpenEXR standard is that if you write an alpha channel, the colors should be premultiplied. The PNG standard states quite explicitly that the colors should never be premultiplied ("straight colors").
jeanphi wrote:Is it absolutely necessary to keep this behaviour? I think it'd be much easier and less surprising to have the same output for all formats (I guess most users won't understand why they see the background during the render and not in their EXR file). For PNG writing you can't unmultiply alpha, that's absolutely impossible because in the same pixel you might have stored values with alpha=1 and values with alpha=0 (glass transmission and glass reflection), so trying to adhere to such a spec is impossible. Better do what the user asks for and let the standard aside in this particular case.
I think we should get back to the previous and simpler version but making sure we have consistent behaviour between all file formats.
Ok, in that case we need to document properly that the output is does not adhere to the standards if you select OpenEXR without premultiply alpha, or premultiply alpha and PNG (when alpha channels are enabled). TGA v2 standard has a field to inform if the colors are premultiplied or not, however this is in an "additional info" block which we don't write. So for TGA we need to inform that the output is "raw".
jeanphi wrote:I think there's a typo in your last commit:
film/fleximage.cpp:950: I find the ! before premultiplyalpha bogus
film/fleximage.cpp:970: ditto
No typo I think, if the colors are not premultiplied already we need to do it before writing the EXR (so that they're always premultiplied one way or another). If no alpha channel is specified we don't do anything.
I'm fine with whatever. If we want to stay within the standards I think my current implementation, along with the docu-text I wrote, is a good effort to do so. It would be nice with some feedback from users who use alpha channels in their workflow, as this is not an area I'm very familiar with.
May contain traces of nuts.