// PoVRay 3.6/3.7 Scene File " ... .pov" /********************************************************************************** Persistence of Vision Ray Tracer Scene Description File File name : sRGB_test.pov Version : 3.7+ Description : Conversion macros between rgb (linear color space) and srgb (standard color space), and with color saturation/brightness macro by Clipka. Date : March 2014 / November 2020 Author : Thomas de Groot E-mail : http://news.povray.org/povray.binaries.images/thread/%3C5f83d3cb%40news.povray.org%3E/?mtop=431959&moff=65 **********************************************************************************/ // +w640 +h900 +a0.3 +am2 +bm2 +bs8 +wt10 //================================================================================= #version 3.8; //================================================================================= // DEFAULTS AND INCLUDES //================================================================================= #include "colors.inc" #include "rand.inc" #include "functions.inc" #include "transforms.inc" #default {pigment {rgb <1,0,0>}} //================================================================================= // GLOBAL SETTINGS //================================================================================= global_settings { assumed_gamma 1 max_trace_level 5 // default [5] radiosity { pretrace_start 0.08 // start pretrace at this size pretrace_end 0.04 // end pretrace at this size count 35 // higher -> higher quality (1..1600) [35] nearest_count 5 // higher -> higher quality (1..10) [5] error_bound 1 // higher -> smoother, less accurate [1.8] recursion_limit 1 // how much interreflections are calculated (1..5+) [3] low_error_factor .3 // reduce error_bound during last pretrace step gray_threshold 0.0 // increase for weakening colors (0..1) [0] minimum_reuse 0.015 // reuse of old radiosity samples [0.015] maximum_reuse 0.1 // new parameter 3.7 [0.2] brightness 1 // brightness of radiosity effects (0..1) [1] adc_bailout 0.01/2 normal off // take surface normals into account [off] media off // take media into account [off] always_sample off // turn sampling in final trace off [on] //max_sample 1.0 // maximum brightness of samples } //noise_generator 2 } // camera ------------------------------------------------------------------ camera { orthographic angle 75 // front view location <0.0 , -0.75 ,-3.0> right x*image_width/image_height look_at <0.0 , -0.75 , 0.0> } // sky ---------------------------------------------------------------------- sphere { 0, 1000 pigment {color Gray50} finish {emission 1} } //--------------------------------------------------------------------------- //transformation functions by Ive: //from scRGB (linear color space) -> sRGB: #declare sRGB_Gamma = function(C) { select(C-0.0031308, C*12.92 , 1.055*pow(C,1/2.4)-0.055) } //and the inverse for sRGB -> scRGB (linear color space): #declare sRGB_GammaInverse = function(C) { select(C-0.04045, C/12.92, pow((C+0.055)/1.055,2.4)) } #macro scRGB_to_sRGB(Color) rgb #end #macro sRGB_to_scRGB(Color) rgb #end //--------------------------------------------------------------------------- //Utilities for converting colors in linear space to sRGB by Cousin Ricky //taken from his srgb.inc (aka CR_srgb.inc). //http://news.povray.org/povray.binaries.scene-files/message/%3C5513104c%241%40news.povray.org%3E/#%3C5513104c%241%40news.povray.org%3E #declare sRGB_fn_Convert = function (x) { select ( 0.0031308 - x, 1.055 * pow (x, 1/2.4) - 0.055, 12.92 * x ) } //Converts a 3-D vector in linear space to sRGB. #macro sRGB_Convert_v (V) #local srgb_V = color V; < sRGB_fn_Convert (srgb_V.red), sRGB_fn_Convert (srgb_V.green), sRGB_fn_Convert (srgb_V.blue) > #end //--------------------------------------------------------------------------- //Bald Eagle's RGB to SRGB (and back) color conversion macro #macro RGB2SRGB (C_linear) #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.04045; #local _Gamma = 2.4; #for (Component, 0, 2) #if (_RGB[Component] <= _Threshold) #local _SRGB[Component] = _RGB[Component] / 12.92; #else #local _SRGB[Component] = pow ((_RGB[Component] + _a)/(1 + _a), _Gamma); #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 //Bald Eagle's SRGB to RGB color conversion macro #macro SRGB2RGB (C_exponential) #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.0031308; #local _Gamma = 2.4; #for (Component, 0, 2) #if (_SRGB[Component] <= _Threshold) #local _RGB[Component] = _SRGB[Component] * 12.92; #else #local _RGB[Component] = ((1 + _a) * pow (_SRGB[Component], 1/_Gamma)) - _a; #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 //--------------------------------------------------------------------------- //Colour saturation/brightness variation code by Clipka. //[povray.advanced-users 15-07-2016: Reverse engineering pigments and textures by BaldEagle]: #macro ColourSat(SatBoost, BrightBoost, Raw) #declare SB = SatBoost; // Saturation boost #declare VB = BrightBoost; // Brightness ("volume") boost #declare RawColour = srgb Raw; #declare SatColour = RawColour-SB; #declare MyColour = SatColour*(1+VB)*RawColour.gray/SatColour.gray; MyColour #end //================================================================================ //------------------------------- objects in scene ------------------------------- //================================================================================ // A test color: // ~~~~~~~~~~~~ #declare MyColor_l = <213, 127, 79>/255; #declare MyColor_s = <213, 127, 79>/255; //Saturation and Brightness values for Clipka's saturation macro: #declare SatBoost = 0.01; #declare BrightBoost = -0.01; //0 = no brightness change; >0 = brighter; <0 = darker // (1) my reference colors: // ~~~~~~~~~~~~~~~~~~~~~~~ // (1a) a color in linear color space box { -1, 1 texture { pigment {rgb MyColor_l} } scale <1, 0.2, 0.1> translate <-1.1, 1.7, 0> } // (1b) a color in standard color space box { -1, 1 texture { pigment {srgb MyColor_s} } scale <1, 0.2, 0.1> translate <1.1, 1.7, 0> } // (2) Ive's: // ~~~~~~~~~ // (2.1a) conversion rgb->srgb of the rgb reference color #local srgbColor1 = scRGB_to_sRGB(MyColor_l); box { -1, 1 texture { pigment {srgbColor1} } scale <1, 0.24, 0.1> translate <-1.1, 0.85, 0> } // (2.1b) saturation/brightness boost added #local BoostCol = ColourSat(SatBoost, BrightBoost, srgbColor1); box { -1, 1 texture { pigment {BoostCol} } scale <1, 0.24, 0.1> translate <-1.1, 0.35, 0> } // (2.2a) conversion back srgb->rgb box { -1, 1 texture { pigment {sRGB_to_scRGB(srgbColor1)} } scale <0.49, 0.24, 0.1> translate <0.6, 0.85, 0> } // (2.2b) conversion back srgb->rgb of the boosted color box { -1, 1 texture { pigment {sRGB_to_scRGB(BoostCol)} } scale <0.49, 0.24, 0.1> translate <0.6, 0.35, 0> } // (2.2c) conversion srgb->rgb of the srgb reference color box { -1, 1 texture { pigment {sRGB_to_scRGB(MyColor_s)} } scale <0.49, 0.49, 0.1> translate <1.6, 0.6, 0> } // (3) Cousin Ricky's: // ~~~~~~~~~~~~~~~~~~ // (3.1a) conversion rgb->srgb of the rgb reference color #local srgbColor2 = rgb sRGB_Convert_v(MyColor_l); box { -1, 1 texture { pigment {srgbColor2} } scale <1, 0.24, 0.1> translate <-1.1, -0.85, 0> } // (3.1b) saturation/brightness boost added box { -1, 1 texture { pigment {ColourSat(SatBoost, BrightBoost, srgbColor2)} } scale <1, 0.24, 0.1> translate <-1.1, -1.35, 0> } // (4) Bald Eagle's: // ~~~~~~~~~~~~~~~~ // (4.1a) conversion rgb->srgb of the rgb reference color #local srgbColor3 = RGB2SRGB(rgb MyColor_l); box { -1, 1 texture { pigment {srgbColor3} } scale <1, 0.24, 0.1> translate <-1.1, -2.55, 0> } // (4.1b) saturation/brightness boost added box { -1, 1 texture { pigment {ColourSat(SatBoost, BrightBoost, srgbColor3)} } scale <1, 0.24, 0.1> translate <-1.1, -3.05, 0> } // (4.2a) conversion back srgb->rgb #local rgbColor4 = SRGB2RGB(srgbColor3); box { -1, 1 texture { pigment {rgbColor4} } scale <0.49, 0.24, 0.1> translate <0.6, -2.55, 0> } // (4.2b) saturation/brightness boost added box { -1, 1 texture { pigment {ColourSat(SatBoost, BrightBoost, rgbColor4)} } scale <0.49, 0.24, 0.1> translate <0.6, -3.05, 0> } // (4.2c) conversion srgb->rgb of the srgb reference color #local rgbColor5 = SRGB2RGB(MyColor_s); box { -1, 1 texture { pigment {rgbColor5} } scale <0.49, 0.49, 0.1> translate <1.6, -2.8, 0> } //================================================================================= text {ttf "arial.ttf", "My reference colours (rgb - srgb)", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-1.5, 2.0, 0> } text {ttf "arial.ttf", "1.a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, 1.65, -0.15> } text {ttf "arial.ttf", "1.b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <0.2, 1.65, -0.15> } //---------------------------- text {ttf "arial.ttf", "Ive's macros", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-0.5, 1.2, 0> } text {ttf "arial.ttf", "RGB ==> sRGB", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-2, -0.1, 0> } text {ttf "arial.ttf", "2.1a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, 0.8, -0.15> } text {ttf "arial.ttf", "2.1b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, 0.3, -0.15> } text {ttf "arial.ttf", "sRGB ==> RGB", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <0.2, -0.1, 0> } text {ttf "arial.ttf", "2.2a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <0.2, 0.8, -0.15> } text {ttf "arial.ttf", "2.2b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <0.2, 0.3, -0.15> } text {ttf "arial.ttf", "2.2c", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <1.2, 0.55, -0.15> } //---------------------------- text {ttf "arial.ttf", "Cousin Ricky's macros", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-1.0, -0.5, 0> } text {ttf "arial.ttf", "RGB ==> sRGB", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-2, -1.8, 0> } text {ttf "arial.ttf", "3.1a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, -0.9, -0.15> } text {ttf "arial.ttf", "3.1b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, -1.4, -0.15> } //---------------------------- text {ttf "arial.ttf", "Bald Eagle's macros", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-0.9, -2.2, 0> } text {ttf "arial.ttf", "RGB ==> sRGB", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <-2, -3.5, 0> } text {ttf "arial.ttf", "4.1a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, -2.6, -0.15> } text {ttf "arial.ttf", "4.1b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <-2, -3.1, -0.15> } text {ttf "arial.ttf", "sRGB ==> RGB", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.1, 0.1, 0.1>} } scale <1, 1.25, 1>*0.2 translate <0.2, -3.5, 0> } text {ttf "arial.ttf", "4.2a", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <0.2, -2.6, -0.15> } text {ttf "arial.ttf", "4.2b", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <0.2, -3.1, -0.15> } text {ttf "arial.ttf", "4.2c", 0.02, 0.0 // thickness, offset texture { pigment {color rgb <0.99, 0.99, 0.99>} finish {diffuse 1} } scale <1, 1.25, 1>*0.15 translate <1.2, -2.85, -0.15> }