POV-Ray : Newsgroups : povray.general : The Alpha Channel : Re: The Alpha Channel Server Time
8 Aug 2024 22:08:07 EDT (-0400)
  Re: The Alpha Channel  
From: Peter J  Holzer
Date: 29 Sep 2000 18:01:14
Message: <slrn8ta0of.r5e.hjp-usenet@teal.h.hjp.at>
On Fri, 29 Sep 2000 16:21:30 +0200, Rune wrote:
>Here's the method. For a given camera ray do this:
>
>Trace the ray and find out what the output-colour would have been
>if the background had been set to be black. Also find out what the
>output-colour would have been if the background had been white. Now
>subtract the first colour-vector from the second. Let's call the
>resulting colour the "difference-colour".
>
>The difference-colour is the impact the background has on the
>output-colour, so this is actually what we want to have stored in the
>alpha channel. However, the alpha channel doesn't store vectors, only
>floats. We must convert the vector into a float. For the percentage
>kind of transparency the difference-colour will *always* be grey, so
>it's no problem to convert that to a float - just take any of the
>3 colour-components (or average them!). But for the other types of
>transparency the difference-colour can be anything. I think the best
>solution would be to take the average of the 3 colour-components.

When converting an RGB value to grey, the components are usually
weighted <0.59, 0.30, 0.11>.

I like it. However, now we have two RGB triplets for every pixel, and
none of them is the correct value to store in a PNG file.

It is pretty easy to compute however. If pb and pw are the RGB color
vectors for black and white background, respectively, we can compute:



    alpha = 1 - tr

    p = pb / alpha

now write p, alpha to the PNG file.

This could even be done now by rendering the scene with a black and
white background and calculating the final image plus alpha from the two
results.

Doing it in Povray will shave off the parse time, but every pixel will
still have to be computed twice. 

I am also a bit worried about reflective surfaces. They may erroneously
show up as "transparent".

	hp

-- 

|_|_) | Sysadmin WSR       | vor dem rechner.

__/   | http://www.hjp.at/ |       at.linux, 2000-09-24


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.