POV-Ray : Newsgroups : povray.programming : merging filtered colors : merging filtered colors Server Time
28 Jul 2024 18:12:58 EDT (-0400)
  merging filtered colors  
From: Matthew Corey Brown - XenoArch
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

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