POV-Ray : Newsgroups : povray.advanced-users : Reverse engineering pigments and textures : Re: Reverse engineering pigments and textures Server Time
17 May 2024 04:25:21 EDT (-0400)
  Re: Reverse engineering pigments and textures  
From: Thomas de Groot
Date: 16 Jul 2016 02:59:35
Message: <5789db57$1@news.povray.org>
On 15-7-2016 22:59, clipka wrote:
> Am 15.07.2016 um 21:06 schrieb Bald Eagle:
>> I am having, and have had in the past, difficulty reproducing the colors in
>> sampled images in my renders.
>>
>> I was wondering if anyone has had success in sampling rgb values from images or
>> "rgb color picker" apps and getting good results in their renders.
>> using sRGB doesn't seem to help me much.
>
> [snip]
>
> I haven't tested it, but you should be able to do it like this:
>
>   #declare SB = 0.2; // Saturation boost
>   #declare VB = 0.4; // Brightness ("volume") boost
>   #declare MyColour = (( srgb <128,255,220>/255 )-SB)*(1+VB);
>
> Note that in this variant the saturation boost also affects the
> brightness, but the upside is that the formula remains simple enough to
> be written in one declaration statement, or even at the very place where
> the colour is actually used.
>
> If you are ok with something more complex but possibly easier to tweak,
> try the following:
>
>   #declare SB = 0.2; // Saturation boost
>   #declare VB = 0.2; // Brightness ("volume") boost
>   #declare RawColour = srgb <128,255,220>/255;
>   #declare SatColour = RawColour-SB;
>   #declare MyColour  = SatColour*(1+VB)*RawColour.gray/SatColour.gray;
>
> This should keep the general brightness unaffected by tweaks to the
> saturation.

Interesting. I am going to play with this a bit :-)

>
>
> Indirect illumination from nearby colourful surfaces, or a general
> non-uniformity in the distribution of colours in the illumination (such
> as a sunny sky, with a yellowish sun and blue sky), may introduce
> additional challenges by also affecting the hue. Countering these may
> prove particularly challenging, and you may end up tweaking each colour
> channel individually. However, the above stable-brightness trick may
> help a bit with this.

Absolutely.

>
>
> In any case, coloures picked from a simple everyday photograph (as
> opposed to a photograph taken under carefully chosen lighting
> conditions) are typically only useful as a starting point, and will
> almost inevitably need a certain degree of tweaking.
>

I was going to say this. I often 'pick' colours from photographs and 
such but only as a basis for further and very substantial tweaking. An 
example of one such exercise is the following fairly simple roof tile 
texture based on colours picked from 'real' tiles photographs:

#declare MedTileTex =
texture {
   pigment {
     cells
     color_map {//colours taken from roof images
       [0.1 srgb <220,158,106>/255]
       [0.2 srgb <217,177,126>/255]
       [0.3 srgb <228,215,173>/255]
       [0.4 srgb <219,152,100>/255]
       [0.5 srgb <166,120, 61>/255]
       [0.6 srgb <225,171,125>/255]
       [0.7 srgb <230,199,142>/255]
       [0.8 srgb <223,187,129>/255]
       [0.9 srgb <236,176,114>/255]
       [1.0 srgb <244,188,131>/255]
     }
     scale <1, 2, 1>*TileScale
   }
   normal {
     average
     normal_map {
       [1 granite 1 scale 0.1]
       [1 cells 2]
     }
     scale <1, 2, 1>*TileScale
   }
   finish {
     specular 0.1
     roughness 0.00286312
     diffuse 0.4
     reflection {0} conserve_energy
   }
}

It can be used for distant view where each colour represents one tile, 
or as a texture for a single tile.


-- 
Thomas


Post a reply to this message

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