POV-Ray : Newsgroups : povray.advanced-users : CIE xyY color space : Re: CIE xyY color space Server Time
27 Apr 2024 12:59:53 EDT (-0400)
  Re: CIE xyY color space  
From: Bald Eagle
Date: 16 Mar 2017 13:00:01
Message: <web.58cac3b955b89017c437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

Excellent information, as always.
Al ways, always, always learning something new and useful here.   :)

> (It should be noted that `srgb <184/255, 115/255, 48/255> * Tone`
> doesn't give you exactly what you are asking for. Theoretically it
> should be `(srgb <184/255, 115/255, 48/255>) * Tone`, but that's
> currently not allowed by the parser.)

So something along the lines of this would be necessary:
(untested, needs handling of optional transmit and filter values)

#macro RGB2SRGB (C_linear)
 // https://en.wikipedia.org/wiki/SRGB
 // C_linear is a standard rgb color vector
 #local RGB = array[3] {C_linear.red, C_linear.green, C_linear.blue};
 #local SRGB = array[3];
 #local _a = 0.055;
 #local _Threshold = 0.0031308;
 #local _Gamma = 2.4;
 #for (Component, 0, 2)
  #if (RGB[Component] <= _Threshold)
   #local SRGB[Component] = 12.92 * RGB[Component];
  #else
   #local SRGB[Component] = ((1 + _a) * pow (RGB[Component], 1/_Gamma)) - _a;
  #end // end if
 #end // end for Component
 #local C_srgb = <SRGB[0], SRGB[1], SRGB[2]>

 C_srgb

#end // end macro RGB2SRGB


Post a reply to this message

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