POV-Ray : Newsgroups : povray.binaries.images : Bronze Age sword - take 1 : Re: Bronze Age sword - take 1 Server Time
2 Dec 2023 20:32:22 EST (-0500)
  Re: Bronze Age sword - take 1  
From: Bald Eagle
Date: 14 Jul 2023 13:45:00
Message: <web.64b18904b039fa5d1f9dae3025979125@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> On 2023-07-14 07:34 (-4), Thomas de Groot wrote:
> > Op 14-7-2023 om 09:23 schreef kurtz le pirate:
> >>
> >> A small remark for lazy people like me, it's shorter to write
> >> <a,b,c>/255 rather than <a/255, b/255, c/255>...
> >>
> > I know. ;-)
> > However, I seem to remember that Clipka once told us that - especially
> > when srgb is involved (not here directly, though) - it would be wiser to
> > write it like I did here. So, being an obedient pupil, I followed
> > (blindly) his advise. :-)
> You remember incorrectly (again).
> https://news.povray.org/6065d1ea%241%40news.povray.org

Ooooooh.  Thomas made a naughty.   :O

I'd say that since we're 30+ years in, maybe we ought to have a macro of some
sort with plenty of explanatory documentation IN the macro code.

#macro SRGB (byteTriplet, optional Multiplier)

 // Converts a byte value <0-255, 0-255, 0-255> to a
 // POV-Ray compliant rgb color vector <0-1, 0-1, 0-1>

 // Usage: SRGB (<r, g, b>)
 // - or -
 //   SRGB (<r, g, b>) * Multiplier

 // From: Cousin Ricky
 // Subject: Re: strange problem with srgb color in light_source
 // https://news.povray.org/606cb0f5%40news.povray.org
 // Here is the general sequence:
 1. An sRGB triplet that comes from a color picker, eyedropper tool, or
    published Web source is typically in the range <0,0,0> ...
    <255,255,255>.  Divide this by 255 to bring it into the range
    <0,0,0> ... <1,1,1>.  This /must/ be done first thing, and is the
    only math that should ever be done at this stage, though it may be
    combined with step 2.

 #local srgbColorVector = byteTriplet/255;

 2. #declare the color with the srgb keyword.  The resulting identifier
    contains a linear color.

 #local RGBcolor = srgb srgbColorVector;

 3. Now, do whatever additional math you need on the identifier.  You may
    do this in a pigment or light_source or wherever.

 // ^^^ leave this for outside of the macro



This, as just a simple prototype.
Something better that takes all the information (filter, transmit, multipliers)
would be nice, and would have sanity checks for out of range values, negative
values, etc.

Maybe I need to go back to the scenes where I was working out the srgb math and
use that to make a documentation infographic, and possibly an animation.

It would be way better to have a nice, fully presented thing in the distribution
that lays out all of the whys and hows, than to have to rehash this topic ever
few years.

Than people can visually and mathematically see what the byte triplet values
are, the in-range nonlinear srgb values are, the in-range linear rgb values, and
how they all relate to one another.   Just do a simple animation from <0, 0, 0>
to <255, 255, 255>, and I think that might very well cover it.
Some examples that simultaneously show the incorrect way to convert from srgb to
rgb would likely be helpful as well.

- BW

Post a reply to this message

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