POV-Ray : Newsgroups : povray.general : color mixing tool : Re: color mixing tool Server Time
30 Jul 2024 02:28:14 EDT (-0400)
  Re: color mixing tool  
From: PM 2Ring
Date: 27 Nov 2009 20:40:00
Message: <web.4b107e3fbf729e20f4c648ed0@news.povray.org>
CShake <cshake+pov### [at] gmailcom> wrote:
> stbenge wrote:
> > If you want to mix colors this way, just use Gimp or another paint
> > program and use the eyedropper tool to the get RGB values, and divide
> > that color vector by 256.
>
> Actually, divide by 255 since there are 256 colors, but they are in the
> range 0-255. #FFFFFF; = <255,255,255>/255 = <1,1,1>

Yes! This is a very common mistake that I've seen in lots of code (in various
languages) over the years.


Here are a couple of colour mixing formulas that I find useful. In these
formulas, C, C0 & C1 are colour vectors, and A is a float, 0 <= A <= 1.

//A weighted mean between colours C0 and C1
C0 * A + C1 * (1-A)

//A muted version of colour C
rgb A + C * (1 - A)

In POV-Ray, it's possible to use negative colours, eg rgb<-1, 0, 0> is identical
to rgb <0, 1, 1>. It's also possible to use colours with components greater than
1, but such colours will get clipped in strong light, so it's probably a good
idea to avoid using this "feature".


Post a reply to this message

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