|
|
Let's start with a relatively simpler example of converting CIE XYZ to
sRGB. The following function is copied from here:
https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Conversions/XyzConverter.cs
internal static IRgb ToColor(IXyz item)
{
// (Observer = 2°, Illuminant = D65)
var x = item.X / 100.0;
var y = item.Y / 100.0;
var z = item.Z / 100.0;
var r = x * 3.2406 + y * -1.5372 + z * -0.4986;
var g = x * -0.9689 + y * 1.8758 + z * 0.0415;
var b = x * 0.0557 + y * -0.2040 + z * 1.0570;
r = r > 0.0031308 ? 1.055 * Math.Pow(r, 1 / 2.4) - 0.055 :
12.92 * r;
g = g > 0.0031308 ? 1.055 * Math.Pow(g, 1 / 2.4) - 0.055 :
12.92 * g;
b = b > 0.0031308 ? 1.055 * Math.Pow(b, 1 / 2.4) - 0.055 :
12.92 * b;
return new Rgb
{
R = ToRgb(r),
G = ToRgb(g),
B = ToRgb(b)
};
}
I think it would be pretty easy to produce a macro that does all of the
above. But how do I turn that into a POV-Ray function? The function
needs to work as a color as well as an isosurface I think.
Mike
Post a reply to this message
|
|