POV-Ray : Newsgroups : povray.general : The Alpha Channel : The Alpha Channel Server Time
8 Aug 2024 22:13:58 EDT (-0400)
  The Alpha Channel  
From: Rune
Date: 29 Sep 2000 10:22:48
Message: <39d4a5b8@news.povray.org>
There are many things concerning the alpha channel that I'd like to see
changed.

When the output-colour is calculated, the background should be ignored in
the output-colour, and only be stored in the output-alpha. Currently the
background is stored in both.

But then a new question arises - exactly *how* should the background be
stored in the alpha channel? How should it be calculated?

Currently the alpha channel behaves strange in many cases. If a transparent
or semi-transparent object is hit, the transmit value of the *first* hit
surface will be stored in the alpha channel. Fog also works strange. Media
is completely ignored I think. I haven't looked into all the different
POV-Ray features but it generally works in a strange and not very useful
way.

I think the alpha channel should take all surfaces and all other effects
into account. There are some problems related to this that I will try to
explain and suggest a solution for.

There are different kinds of transparency in POV-Ray. Some effects take up a
certain percentage of the output-colour. One example of that is surfaces
with transmit values. Another example is fog (that includes fog with no
transmit value).

However, there are also different kinds of transparency that adds,
subtracts, multiplies, or divides the output-colour with something. For
example media and surfaces with filter values.

The problem is that the alpha channel (not just in POV-Ray, but in general)
is designed for only the kind of transparency that takes up a percentage of
the output-colour. So the other kinds of transparency can not be stored in
the alpha channel - at least not without being converted first.

I think that POV-Ray, when the alpha channel is turned on, should convert
all kinds of transparency into the kind that can be stored in the alpha
channel. I know that it will not work 100% correct, but it's the only option
if we want to be able to use effects such as media together with the alpha
channel.

The good news is that there's a simple way to convert any kind of
transparency into the percentage kind of type that can be stored in the
alpha channel. The method is a very general one. For the percentage type of
transparency it will be calculated completely accurate. For other types of
transparency it will convert it in a somewhat meaningful way.

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.

And that's it actually. As you can see, no matter what effects are used, the
alpha channel can always be found by taking the average of the 3 colour
components of the difference-colour. Because the method is so general, it
will also automatically work when new features are implemented in POV-Ray.

So, what do you think of this solution? I'd like to hear your opinions.

Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated August 7)
/ Also visit http://www.povrayusers.org


Post a reply to this message

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