non pre-multiplied alpha

Started by kirk12, August 21, 2009, 04:14:52 PM

Previous topic - Next topic

kirk12

I would like to compose some of  my rendered clouds with real one from a photo. The alpha images produced by default is a bit weird because they are actually have the sky blue ( not black as it should be for a clear alpha imho). I managed to do true alpha as a separate render with a black sky but still have a problem. I need the main RGB image to show translucent edges not being translucent ( not pre-multiplied with a background) to have clear edges without a halo of  background color when I compose the render with other image.
Does Terragen 2 have any trick to do so?  

Matt

#1
If you render without atmosphere (either by disabling the atmosphere completely or just disabling "primary" on the atmosphere), your clouds RGB and alpha should be correct for compositing with other images using the "over" composite operation which is pretty standard for compositing CG elements. The clouds will be premultiplied by the alpha, but that's what you should have. Can you show me an example of how it doesn't look right?

If you're compositing using some other mode and you really need to unpremultiply, you could try dividing the RGB by the alpha image, but that might not be very reliable.

(BTW, the reason the alpha images produced by default include a blue sky is because they include the "spectral alpha" of the atmosphere, so that you can composite the atmosphere as well as the clouds.)

Matt
Just because milk is white doesn't mean that clouds are made of milk.

kirk12

#2
Quote from: Matt on August 21, 2009, 08:07:37 PM
If you render without atmosphere (either by disabling the atmosphere completely or just disabling "primary" on the atmosphere), your clouds RGB and alpha should be correct for compositing with other images using the "over" composite operation which is pretty standard for compositing CG elements. The clouds will be premultiplied by the alpha, but that's what you should have.


I am not sure I understand it right. Do you mean "overlay" compositing mode?   Could you be a little more specific on that please.

As regards of dividing the rgb by the alpha it is what I am trying to do but unfortunately it doesn't work good in every situation.  Actually I would like to have a separate unpremultipied rgb output + alpha not only for clouds.  It would be very useful to have for any  chosen thing in the scene including shadows. Would be a great feature.

Matt

#3
I only really know this from Nuke, I'm afraid. With "over" compositing, the background RGB is multiplied by the inverse of your foreground alpha, then the foreground RGB is added on top. That requires your foreground RGB to be premultiplied. Rendering onto a black background gives you premultiplied elements which is why this compositing mode is really convenient for CG. I don't really have a way to render unpremultiplied elements yet, although maybe we could add that. It would probably just be the equivalent of what I would do in the 2D compositor to obtain an unpremultiplied version though. What software are you compositing in?

If you work with EXRs it should be possible to unpremultiply them. They should be linear (won't have TG's gamma, soft clip or contrast effects applied).

Matt
Just because milk is white doesn't mean that clouds are made of milk.

kirk12

Thanks a lot.   I don't have an expensive 2d compositer  but the method you described works  fine with a bit color correction in almost any 2d software. Also unpremultipling EXR gives much better result. Thanks for the hint too. It actually does what I need.

mecha

This is an extremely valuable thread. I have been unable to find any valuable information on rendering alpha out of Terragen 2 thus far. Consider this a request for more detailed alpha documentation!

Also, can anyone provide good reference on the "over compositing" technique mentioned here?