POV-Ray : Newsgroups : povray.programming : Combining POV-Ray colors in a program. : Re: Combining POV-Ray colors in a program. Server Time
14 Jun 2024 06:10:08 EDT (-0400)
  Re: Combining POV-Ray colors in a program.  
From: Allen
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

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