POV-Ray : Newsgroups : povray.programming : merging filtered colors Server Time
28 Jul 2024 16:26:07 EDT (-0400)
  merging filtered colors (Message 1 to 3 of 3)  
From: Matthew Corey Brown - XenoArch
Subject: merging filtered colors
Date: 11 Dec 1999 19:11:18
Message: <3852E825.54C6B1B2@xenoarch.com>
i have 2 colors with various FILTER and TRANSM values.. lets call them
front and back
how do i combine these two colors such that the resulting color
will filter light as if it came through the back one first then the
front.
I can get the RGB values... but the FILTER value is tricky (I think i
got
the TRANSM just multiply the two) any pointers?
this is my current function i'm working with (I realize FILTER is no
where near right)

void MergeColour(COLOUR Fil,COLOUR Back) {
	DBL mask,fm;
	mask = 1.0-Fil[TRANSM];
	fm = Fil[FILTER]*mask; 
	Fil[RED] = Back[RED]*Fil[RED]*fm + Fil[RED]*mask +
Back[RED]*Fil[TRANSM]; 
	Fil[GREEN] = Back[GREEN]*Fil[GREEN]*fm + Fil[GREEN]*mask +
Back[GREEN]*Fil[TRANSM]; 
	Fil[BLUE] = Back[BLUE]*Fil[BLUE]*fm + Fil[BLUE]*mask +
Back[BLUE]*Fil[TRANSM]; 
	Fil[FILTER] *= Back[FILTER];
	Fil[TRANSM] *= Back[TRANSM];
}

-- 
Matthew Corey Brown                                         XenoArch
mcb### [at] xenoarchcom                             http://www.xenoarch.com


Post a reply to this message

From: Nathan Kopp
Subject: Re: merging filtered colors
Date: 12 Dec 1999 01:22:30
Message: <38533f26@news.povray.org>
Merging them into one I think would be impossible due to limitations in the
RGBFT light model.  If we instead used r,g,b,rf,gf,bf (with a filter amount
for each color channel), then they could be combined easily.

However, to filter/transmit incoming light properly through two layers that
use filter and transmit, you would do something like the following:

/* first filter through the first layer */
for(i=0; i<3; i++)
  Output[i] = Input[i]*Fil[TRANSM] + Input[i]*Fil[i]*Fil[FILTER];

/* now repeat fo the second layer */
Assign_Colour(Input, Output);

for(i=0; i<3; i++)
  Output[i] = Input[i]*Fil[TRANSM] + Input[i]*Fil[i]*Fil[FILTER];

-Nathan

Matthew Corey Brown - XenoArch <mcb### [at] xenoarchcom> wrote...
> i have 2 colors with various FILTER and TRANSM values.. lets call them
> front and back
> how do i combine these two colors such that the resulting color
> will filter light as if it came through the back one first then the
> front.
> I can get the RGB values... but the FILTER value is tricky (I think i
> got
> the TRANSM just multiply the two) any pointers?
> this is my current function i'm working with (I realize FILTER is no
> where near right)
>
> void MergeColour(COLOUR Fil,COLOUR Back) {
> DBL mask,fm;
> mask = 1.0-Fil[TRANSM];
> fm = Fil[FILTER]*mask;
> Fil[RED] = Back[RED]*Fil[RED]*fm + Fil[RED]*mask +
> Back[RED]*Fil[TRANSM];
> Fil[GREEN] = Back[GREEN]*Fil[GREEN]*fm + Fil[GREEN]*mask +
> Back[GREEN]*Fil[TRANSM];
> Fil[BLUE] = Back[BLUE]*Fil[BLUE]*fm + Fil[BLUE]*mask +
> Back[BLUE]*Fil[TRANSM];
> Fil[FILTER] *= Back[FILTER];
> Fil[TRANSM] *= Back[TRANSM];
> }
>
> --
> Matthew Corey Brown                                         XenoArch
> mcb### [at] xenoarchcom                             http://www.xenoarch.com


Post a reply to this message

From: Chris Huff
Subject: Re: merging filtered colors
Date: 12 Dec 1999 09:11:11
Message: <chrishuff_99-81256F.09113812121999@news.povray.org>
In article <38533f26@news.povray.org>, "Nathan Kopp" <Nat### [at] Koppcom> 
wrote:

> Merging them into one I think would be impossible due to limitations in 
> the RGBFT light model.  If we instead used r,g,b,rf,gf,bf (with a filter 
> amount for each color channel), then they could be combined easily.

This sounds close to what I tried to accomplish with my transparency 
patch, except my patch would allow you to use multiplicative, additive, 
subtractive, average, and various other filters(using the word in the 
sense of Photoshop filters), with a pattern and color_map for each one.
This would be very useful for layered textures, unfortunately I never 
got it to work. The transparency patch I have distributed only does 
blurring of the transparency, which is still specified the old way.

Maybe I will get back to work on this patch, now that I have a bit more 
experience programming and a better knowledge of the POV source.

-- 
Chris Huff
e-mail: chr### [at] yahoocom
Web page: http://chrishuff.dhs.org/


Post a reply to this message

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