Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!ucsfcgl!pixar!fishkin From: fishkin@pixar.UUCP (Ken Fishkin) Newsgroups: comp.graphics Subject: Re: RGB color mixing/averaging Keywords: RGB, super-sampling, transparency Message-ID: <9628@pixar.UUCP> Date: 16 Mar 90 17:09:51 GMT References: <173@yak.COM> <6020@becker.UUCP> Reply-To: fishkin@pixar.UUCP (Ken Fishkin) Organization: Pixar -- Marin County, California Lines: 30 In article <173@yak.COM> tpd6908@yak.COM (Tom Dickens) writes: |I am looking for a simple routine that will take 2 rgb values, a ratio |for mixing them (ie. 0.5), and will return the resulting rgb value. |This is desired for determining a pixel color after super-sampling, or when |combining colors while working with transparent surfaces. | |The problem I have is I expect the resulting rgb value to follow |'real world' results. (ie. case1: red+blue=purple, case2: blue+yellow=green) [various proposals for 'real world' results deleted]. The confusion is due to the vagueness of the term "real world results". Different color models and algorithms are appropriate for modeling different phenomona. For modeling the effect of collecting light rays (as in the results obtained from super-sampling a surface), any additive color space is appropriate: RGB, XYZ, etc. For modeling the effect of shining light through a colored filter, you have to go to wavelength-based spaces like XYZ. For modeling the effect of combining colored paints (what I believe Mr. Dickens is alluding to with his "real world" examples), you have to go to XYZ space and do some awful, complicated physics, which will require you to know the _chemical_ as well as _optical_ properties of the paints, the surface the paints lie on, and so forth. Trust me: I did my masters on this. A quick-and-dirty approximation is to linearly interpolate in HSL (note: not HSV!) space, after re-mapping the hue wheel such that Red, _Yellow_, and Blue form an equilateral triangle within the whell. Hope this helps, -- Ken Fishkin ...ucbvax!pixar!fishkin