|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
Post a reply to this message
Attachments:
Download 'rgb_srgb_1.inc.txt' (2 KB)
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike Horvath <mik### [at] gmailcom> wrote:
> 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
That was the general (original) idea.
Seems to work fine (so far...) .
#declare Tone2 = <1.2, 1.2, 0.3>;
#declare Wood = texture {
pigment {
wood
color_map {
[0.0 rgb SRGB2RGB(<121, 52, 13>/255) * Tone2]
//[0.2 srgb <142, 73, 18>/255 * Tone2]
[0.4 rgb SRGB2RGB(<184, 115, 48>/255) * Tone2]
//[0.6 srgb <157, 81, 23>/255 * Tone2]
//[0.8 srgb <108, 45, 4>/255 * Tone2]
[1.0 rgb SRGB2RGB(<156, 72, 26>/255) * Tone2]
}
warp {turbulence <0.6, 0.1, 0.1>*0.5}
scale <0.1, 0.1, 10>*0.5
translate y*0.1
rotate y*90
} // end pigment
normal {
wood
warp {turbulence <0.6, 0.1, 0.1>*0.5}
scale <0.1, 0.1, 10>*0.5
translate y*0.1
rotate y*90
} // end normal
scale 2
} // end texture
#declare Wood2 = texture {Wood rotate x*90 scale 0.7}
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Am 17.03.2017 um 21:56 schrieb Bald Eagle:
> Mike Horvath <mik### [at] gmailcom> wrote:
>
>> 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
>
> That was the general (original) idea.
>
> Seems to work fine (so far...) .
>
> #declare Tone2 = <1.2, 1.2, 0.3>;
> #declare Wood = texture {
> pigment {
> wood
> color_map {
> [0.0 rgb SRGB2RGB(<121, 52, 13>/255) * Tone2]
...
I think you're talking about two different things:
- `srgb` not being allowed in parentheses (same as `rgb`, btw), which is
what you're working around, and which you just /happen/ to need in a
color_map.
- `color_map` always being interpolated in linear colour space, even if
colours are being specified using `srgb`, which I guess is what Mike is
talking about (and which the current 3.7.1 beta solves by providing the
`blend_mode` and `blend_gamma` settings).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
On 2017-03-17 12:34 PM (-4), Bald Eagle wrote:
> 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.
I wrote a related include file that might also be useful. It can
convert linear colors to sRGB hexadecimal strings.
http://news.povray.org/povray.binaries.scene-files/message/%3C5513104c%241%40news.povray.org%3E/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|