|
|
On 3/17/2017 12:34 PM, Bald Eagle wrote:
> I hope I got this correct.
>
> Some brief experiments indicate that it ought to have a dramatic impact on
> "washed-out" scenes resulting from using image color values reported by 3rd
> party sampling software.
>
> Please test and give me some feedback for problems, suggestions, or
> improvements.
>
> Plain text follows, "include" file attached.
>
>
> #macro RGB2SRGB (C_linear)
> // POV-Ray SDL macro - March 2017 - Bill Walker "Bald Eagle"
> // Version 1.0
> // Converts a color in RGB color space to a color in sRGB color space
> // https://en.wikipedia.org/wiki/SRGB
> // Input: C_linear is a standard rgb color vector <R, G, B, [F], [T]>
> // Output: < Red, Green, Blue, Filter, Transmit >
> #local _Color = color C_linear;
> #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] = RGB[Component] * 12.92;
> #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], _Color.filter, _Color.transmit>;
>
> C_srgb
>
> #end // end macro RGB2SRGB
>
> #macro SRGB2RGB (C_exponential)
> // POV-Ray SDL macro - March 2017 - Bill Walker "Bald Eagle"
> // Version 1.0
> // Converts a color in sRGB color space to a color in RGB color space
> // https://en.wikipedia.org/wiki/SRGB
> // Input: C_exponential is a standard rgb color vector <R, G, B, [F], [T]>
> // Output: < Red, Green, Blue, Filter, Transmit >
> // Usage: rgb SRGB2RGB(<Red, Green, Blue>)
> // Usage (e.g. for sampled colors): rgb SRGB2RGB(<Red, Green, Blue>/255) *
> [Modifier]
> #local _Color = color C_exponential;
> #local SRGB = array[3] {C_exponential.red, C_exponential.green,
> C_exponential.blue};
> #local RGB = array[3];
> #local _a = 0.055;
> #local _Threshold = 0.04045;
> #local _Gamma = 2.4;
> #for (Component, 0, 2)
> #if (SRGB[Component] <= _Threshold)
> #local RGB[Component] = SRGB[Component] / 12.92;
> #else
> #local RGB[Component] = pow ((SRGB[Component] + _a)/(1 + _a), _Gamma);
> #end // end if
> #end // end for Component
> #local C_rgb = <RGB[0], RGB[1], RGB[2], _Color.filter, _Color.transmit>;
>
> C_rgb
>
> #end // end macro SRGB2RGB
>
What can you use this script for? Can you use it in color maps? IIRC
sRGB doesn't behave as expected in color maps.
Mike
Post a reply to this message
|
|