POV-Ray : Newsgroups : povray.advanced-users : Reverse engineering pigments and textures : Re: Reverse engineering pigments and textures Server Time
24 Apr 2024 10:27:32 EDT (-0400)
  Re: Reverse engineering pigments and textures  
From: clipka
Date: 15 Jul 2016 16:59:58
Message: <57894ece$1@news.povray.org>
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.

You have to remember that the colour you see in images is not a
straightforward material colour, but a combination of (a) the material
colour, (b) the surface finish, (c) the geometry, (d) the direct
illumination from light sources, and (e) the indirect illumination via
other objects.

Presuming an overall white illumination, the most important factors will be:

(1) Darkening from shadows and/or the light hitting the surface at a
shallow angle. This corresponds to a mixing with black.

(2) Brightening from (possibly very dull) highlights. This corresponds
to a mixing with white.

In combination, they correspond to a change in total brightness and
desaturation. To counter this, you'll usually have to boost both the
brightness by multiplying all channels by another constant value, and
the saturation by subtracting another constant value from all channels.
By how much, that's a thing you'll have to figure out by tweaking.

Note that these changes need to be applied _after_ converting the picked
colour values to linear colour space; this is especially true for the
boosting of the saturation, which would otherwise cause a shift in hue.

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.


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.


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.


Post a reply to this message

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