POV-Ray : Newsgroups : povray.programming : Combining POV-Ray colors in a program. Server Time
22 Dec 2024 07:01:03 EST (-0500)
  Combining POV-Ray colors in a program. (Message 1 to 6 of 6)  
From: Allen
Subject: Combining POV-Ray colors in a program.
Date: 30 Sep 2005 19:55:01
Message: <web.433dcf3c2c4f4f5d6240e2de0@news.povray.org>
I've been working on a program for a while that is a color picker.
Currently it only supports red, green, blue, and transmit, but I would like
to add filter support as well.  What I need to know is the math used to
create a preview color from a solid background color and a foreground color
containing transmit and filter values.  I've looked through the source code
for POV-Ray, but have some difficulty in understanding some of it.  I would
greatly appreciate it if anyone could help me out.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Combining POV-Ray colors in a program.
Date: 30 Sep 2005 20:04:42
Message: <433dd29a$1@news.povray.org>
Allen wrote:
> I've been working on a program for a while that is a color picker.
> Currently it only supports red, green, blue, and transmit, but I would like
> to add filter support as well.  What I need to know is the math used to
> create a preview color from a solid background color and a foreground color
> containing transmit and filter values.  I've looked through the source code
> for POV-Ray, but have some difficulty in understanding some of it.  I would
> greatly appreciate it if anyone could help me out.

There is no real point in "previewing" a filter or transmit value as the 
result does not depend on the color but that what you call the "background", 
which actually means the recursive ray-tracing result color.  BUT, that is 
what you cannot just compute by one simple mathematical formula ...

	Thorsten


Post a reply to this message

From: Slime
Subject: Re: Combining POV-Ray colors in a program.
Date: 30 Sep 2005 21:55:42
Message: <433dec9e$1@news.povray.org>
> There is no real point in "previewing" a filter or transmit value as the
> result does not depend on the color but that what you call the
"background",
> which actually means the recursive ray-tracing result color.  BUT, that is
> what you cannot just compute by one simple mathematical formula ...


Well, if you display the color over the typical checkerboard background,
then you can filter and transmit that as the background to demonstrate the
color.

I believe the formula Allen is looking for would be something along the
lines of

red = color.red * (1 - color.transmit) * (1 - color.filter) + color.transmit
* whateversbehind.red + color.filter*color.red*whateversbehind.red
(same for green, blue)

I'm not sure if that's right. It should be in the source somewhere (though
not as clearly as this)...

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Christoph Hormann
Subject: Re: Combining POV-Ray colors in a program.
Date: 1 Oct 2005 03:25:01
Message: <dhldbb$2l0$1@chho.imagico.de>
Allen wrote:
> I've been working on a program for a while that is a color picker.
> Currently it only supports red, green, blue, and transmit, but I would like
> to add filter support as well.  What I need to know is the math used to
> create a preview color from a solid background color and a foreground color
> containing transmit and filter values.  I've looked through the source code
> for POV-Ray, but have some difficulty in understanding some of it.  I would
> greatly appreciate it if anyone could help me out.

You should have a look at the docs, section 3.2.1.5 'Specifying Colors'. 
  This pretty well explains the meaning of the color vector components.

You won't find a formula for this in the POV-Ray source since there 
isn't any place where this needs to be calculated.

Christoph

-- 
POV-Ray tutorials, include files, Landscape of the week:
http://www.tu-bs.de/~y0013390/ (Last updated 24 Jul. 2005)
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: Allen
Subject: Re: Combining POV-Ray colors in a program.
Date: 1 Oct 2005 12:25:00
Message: <web.433eb730337688b769bc148e0@news.povray.org>
I'm not trying to get a perfect preview, because there are to many things to
take into consideration.  I just want the program to show a general idea of
what may be expected.  The following is a sample file of what I'm trying to
do.  There are two planes, a solid one in the back and a transparent one in
the front.  A sphere in front of the planes has its color computed from the
two plane colors.  The diffuse is 0.0 and ambient is 1.0.  The sphere color
should blend in with the rest (it does with only tranmsit, but not with
filter).

// Declare solid back and transparent front color
#declare CB = color rgb <0.5, 0.3, 0.7>;
#declare CF = color rgbft <0.1, 0.9, 0.1, 0.0, 0.7>;

// Compute visible color
// #declare R = CF.red * (1 - CF.transmit) * (1 - CF.filter) + CF.transmit *
CB.red + CF.filter * CF.red * CB.red;
// #declare G = CF.green * (1 - CF.transmit) * (1 - CF.filter) + CF.transmit
* CB.green + CF.filter * CF.green * CB.green;
// #declare B = CF.blue * (1 - CF.transmit) * (1 - CF.filter) + CF.transmit
* CB.blue + CF.filter * CF.blue * CB.blue;

#declare R = CF.red * (1 - CF.transmit) + CB.red * CF.transmit;
#declare G = CF.green * (1 - CF.transmit) + CB.green * CF.transmit;
#declare B = CF.blue * (1 - CF.transmit) + CB.blue * CF.transmit;


#declare CO = color rgb <R, G, B>;

// Camera
camera
    {
    location <0, 0, -12>
    look_at <0, 0, 0>

    right x * image_width / image_height
    up y
    }

// A plane in the back
plane
    {
    -z, 7

    texture
        {
        pigment
            {
            color CB
            }
        finish
            {
            diffuse 0
            ambient 1
            }
        }
    }

// A plane in the front
plane
    {
    -z, 8

    texture
        {
        pigment
            {
            color CF
            }
        finish
            {
            diffuse 0
            ambient 1
            }
        }
    }

// An object with the same visible color
sphere
    {
    <0.5, 0, -9>, 0.2

    texture
        {
        pigment
            {
            color CO
            }
        finish
            {
            diffuse 0
            ambient 1
            }
        }
    }




Christoph Hormann <chr### [at] gmxde> wrote:
> Allen wrote:
> > I've been working on a program for a while that is a color picker.
> > Currently it only supports red, green, blue, and transmit, but I would like
> > to add filter support as well.  What I need to know is the math used to
> > create a preview color from a solid background color and a foreground color
> > containing transmit and filter values.  I've looked through the source code
> > for POV-Ray, but have some difficulty in understanding some of it.  I would
> > greatly appreciate it if anyone could help me out.
>
> You should have a look at the docs, section 3.2.1.5 'Specifying Colors'.
>   This pretty well explains the meaning of the color vector components.
>
> You won't find a formula for this in the POV-Ray source since there
> isn't any place where this needs to be calculated.
>
> Christoph
>
> --
> POV-Ray tutorials, include files, Landscape of the week:
> http://www.tu-bs.de/~y0013390/ (Last updated 24 Jul. 2005)
> MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: Allen
Subject: Re: Combining POV-Ray colors in a program.
Date: 2 Oct 2005 16:05:01
Message: <web.43403c5a337688b78965f9b20@news.povray.org>
I've added the feature using the formula suggested by Slime (thanks).  It
seems to work reasonably well for its purpose.  If you would like to see
it, visit povcolor.sourceforge.net or sourceforge.net/projects/povcolor.
Any additional comments on the preview mechanism is appreciated.


Post a reply to this message

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