POV-Ray : Newsgroups : povray.programming : Background colours and antialiasing Server Time
28 Jul 2024 18:12:31 EDT (-0400)
  Background colours and antialiasing (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: Peter Popov
Subject: Re: Background colours and antialiasing
Date: 31 Jul 2000 03:39:20
Message: <euaaosoiip6nq85g3o756bm0n3bo0sn86f@4ax.com>
On Mon, 31 Jul 2000 17:12:33 +1200, "Edmund Horner"
<ejr### [at] paradisenetnz> wrote:

>Hello all.
>
>Lately I've been planning to raytrace a whole lot of graphics for a game I'm
>making...  Antialiased pictures would be nicer, of course, but that leaves
>the issue of which background colour to use for the rendering.

Use the alpha channel output (+UA with png or tga output). The alpha
channel, as POV interprets it, is an additional channel in the image
which represents the amount of "presense" in a pixel. The background
(or sky_sphere) get a 0 and a direct hit in an object gets 255.
Antialiasing does its job here, too, so anything in between 0 and 255
will happen on the edges of objects, which you find problematic.

Now, with the alpha channel output, you can open the graphic in a
paint program and defringe the edges so that the background color is
removed. In PhotoShop, you have to set the background to whatever it
is in your scene, open the file, load the alpha channel as a
selection, copy then paste to a new file, and then defringe.

If you don't have PhotoShop available, I am certain the GIMP or
PaintShop Pro have such abilities. If they do not, you can come up
with the same result using MegaPOV post-processing, but it will be
more tedious.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] usanet
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Pabs
Subject: Re: Background colours and antialiasing
Date: 31 Jul 2000 03:48:52
Message: <39852F73.F504F18C@hotmail.com>
Edmund Horner wrote:

> Hello all.
>
> Lately I've been planning to raytrace a whole lot of graphics for a game I'm
> making...  Antialiased pictures would be nicer, of course, but that leaves
> the issue of which background colour to use for the rendering.
>
> I think it would be nice to have an AA mode that does _NOT_ affect pixels
> that touch the background, thus making AA pictures work fine with all colour
> backgrounds.
>
> I hope the above makes some sense!
>
> I'm not sure whether this would mean a new AA mode (e.g. +AM3), or what, but
> it would be very nice!

Put one of the following in your commandline/ini file
Output_Alpha=bool ;Sets alpha output on/off
+UA ;Sets alpha output on
-UA ;Sets alpha output off
Note that to output the alpha channel you must be using either .tga or .png
output
Read the docs for "File Output Options" and "Image maps" - down the bottom under
"Using the Alpha Channel"

You may or may not be able to use these formats & might want to export the alpha
channel as a greyscale image & remove it.

Hope this was of some help.

--
Bye
Pabs


Post a reply to this message

From: Edmund Horner
Subject: Re: Background colours and antialiasing
Date: 31 Jul 2000 05:55:58
Message: <39854d2e@news.povray.org>
Thanks guys for the advice, I'm glad I can do it without resorting to
fiddling with the pov code.

"Edmund Horner" <ejr### [at] paradisenetnz> wrote in message
news:39850ac9@news.povray.org...
> Hello all.
>
> Lately I've been planning to raytrace a whole lot of graphics for a game
I'm
> making...  Antialiased pictures would be nicer, of course, but that leaves
> the issue of which background colour to use for the rendering.
>
> I think it would be nice to have an AA mode that does _NOT_ affect pixels
> that touch the background, thus making AA pictures work fine with all
colour
> backgrounds.
>
> I hope the above makes some sense!
>
> I'm not sure whether this would mean a new AA mode (e.g. +AM3), or what,
but
> it would be very nice!
>
> Thanks,
> Edmund.
>
>


Post a reply to this message

From: Edmund Horner
Subject: Re: Background colours and antialiasing
Date: 25 Aug 2000 07:15:28
Message: <39a65550$1@news.povray.org>
> The alpha channel, as POV interprets it, is an additional channel in the
image
> which represents the amount of "presense" in a pixel. The background
> (or sky_sphere) get a 0 and a direct hit in an object gets 255.
> Antialiasing does its job here, too, so anything in between 0 and 255
> will happen on the edges of objects, which you find problematic.

So do pixels with a partial alpha channel (such as those on the edge of an
object) contain any colour from the background or skysphere?

I am about to create a tool that fixes the images I want from PNGs, so I
need to know if I can treat all non-zero alpha's as 255.


Post a reply to this message

From: Warp
Subject: Re: Background colours and antialiasing
Date: 25 Aug 2000 07:40:43
Message: <39a65b3a@news.povray.org>
Edmund Horner <ejr### [at] paradisenetnz> wrote:
: So do pixels with a partial alpha channel (such as those on the edge of an
: object) contain any colour from the background or skysphere?

  Of course.
  If, for example, at a certain pixel due to antialiasing the color is 50%
the color of the object and 50% the color of the background, then the alpha
value will also be 50%. The color of the pixel will be a mixture between
the color of the object and the color of the background.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Edmund Horner
Subject: Re: Background colours and antialiasing
Date: 25 Aug 2000 09:54:28
Message: <39a67a94@news.povray.org>
So what do you think I can do to eliminate the background influence?

"Warp" <war### [at] tagpovrayorg> wrote in message
news:39a65b3a@news.povray.org...
> Edmund Horner <ejr### [at] paradisenetnz> wrote:
> : So do pixels with a partial alpha channel (such as those on the edge of
an
> : object) contain any colour from the background or skysphere?
>
>   Of course.
>   If, for example, at a certain pixel due to antialiasing the color is 50%
> the color of the object and 50% the color of the background, then the
alpha
> value will also be 50%. The color of the pixel will be a mixture between
> the color of the object and the color of the background.
>
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Background colours and antialiasing
Date: 25 Aug 2000 16:25:19
Message: <39a6d62f@news.povray.org>
Edmund Horner <ejr### [at] paradisenetnz> wrote:
: So what do you think I can do to eliminate the background influence?

  Don't use antialiasing.

  I can't think of any other way. There's no way of antialiasing only the
sharp changes in color that do not take the background as one color (at least
not in any current povray).

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Peter Harris
Subject: Re: Background colours and antialiasing
Date: 28 Aug 2000 12:06:40
Message: <39aa8e10$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:39a6d62f@news.povray.org...
> Edmund Horner <ejr### [at] paradisenetnz> wrote:
> : So what do you think I can do to eliminate the background influence?
>
>   Don't use antialiasing.

Or render against a black background. (The black, at least, won't taint your
colour when you eventually mix with your final background.)

Peter Harris


Post a reply to this message

From: Warp
Subject: Re: Background colours and antialiasing
Date: 28 Aug 2000 12:21:07
Message: <39aa9172@news.povray.org>
Peter Harris <pet### [at] hclcom> wrote:
: Or render against a black background. (The black, at least, won't taint your
: colour when you eventually mix with your final background.)

  It will still have influence in the color of the object: It will darken it.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Peter Harris
Subject: Re: Background colours and antialiasing
Date: 28 Aug 2000 18:26:52
Message: <39aae72c@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:39aa9172@news.povray.org...
> Peter Harris <pet### [at] hclcom> wrote:
> : Or render against a black background. (The black, at least, won't taint
your
> : colour when you eventually mix with your final background.)
>
>   It will still have influence in the color of the object: It will darken
it.

Well, yes. But given that the point of having an alpha channel available is to
blend with other information (a static background, for example), this is not
unreasonable.

For something like POV, a more accurate method such as:

[ S * A + D * (MAX - A) ] / MAX

might be used. However, for quick applications (games, realtime overlays) a
pre-darkened image actually saves a multiply (at the cost of a bit or so of
accuracy):

S + [(D * (MAX - A))/MAX]

Of course, the PNG spec requires a non-premultiplied alpha. How close to the
spec is POV? I imagine that POV ignores this portion of the spec, as it is
non-trivial to get right in the case of any background other than black.
Writing a simple little program to 'correct' a given .PNG when you can
guarantee that it was blended vs. black (or white, for that matter) would be
fairly easy. Colour accuracy would get pretty bad as pixels approached
transparent, though. I suspect that it would be better as a patch to MegaPOV.


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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