POV-Ray : Newsgroups : povray.binaries.images : Stock colors and assumed_gamma 1 in POV-Ray 3.6 : Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6 Server Time
24 Apr 2024 19:05:52 EDT (-0400)
  Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6  
From: Kenneth
Date: 14 Oct 2020 06:00:01
Message: <web.5f86caca76c60ba8d98418910@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Hi Kenneth - this is something that I was concerned about, tried to
> address, and IIRC, did it backwards.
>
> Maybe you can take a look, and see what you think.
>
>
http://news.povray.org/povray.text.scene-files/thread/%3Cweb.58cc101945a951b1c437ac910%40news.povray.org%3E/
>

I'm genuinely sorry to say that I didn't take note of your color-conversion
macros at the time (March 2017.) That is some NICE work.

I just spent a couple of enjoyable and challenging hours, going through your
macros' code there, and comparing it to the Wikipedia 'conversion' formulae (at
Wikipedia's "srgb" entry). Your math looks to be spot-on-- but of course you're
better at math than I am. ;-) Thanks for the opportunity for the mathematical
'brain boost'.

And you are correct-- your two macros are *reversed* as to their respective
operations! Through no fault of your own: the Wikipedia formulae themselves are
REVERSED. Which may mean that Wikipedia's source for those formulae is also
wrong. I'm amazed that no one has yet corrected the Wikipedia article.

'Fixing' your two macros is a simple matter-- just rename RGB2SRGB(C_linear) as
SRGB2RGB(C_exponential), ha. And vice-versa.

Having done so myself, I converted rgb <.75,.75,.75> to its srgb equivalent.
Result: <0.522522,0.522522,0.522522>

Compare that to:
#declare MY_PIG = pigment{srgb .75}
#debug concat(
"\n","srgb color = <",vstr(3,eval_pigment(MY_PIG, <.2,.2,.2>),",
",0,6),">","\n")
// Result: <0.522522,0.522522,0.522522>

A perfect match. Congrats!

As I experimented with your macros, three things pointed me to the conclusion
that the macro operations were reversed:
1) Your own hint ;-)
2) My *original* <.75,.75,.75> rgb-to-srgb result was 0.880825 -- which was
clearly wrong.
3) In the (mis-named) RGB2SRGB macro, at the near-ending line of
       #local C_srgb = ...
I changed that on a whim to
       #local C_srgb = srgb ....
and the #debug result was... <.75,.75,.75> -- the same as the original color! In
other words, it was first converting the color to (rgb) 0.880825 by the formula,
then #re*-converting it back to (srgb) 0.75. So *something* was amiss somewhere!

Btw, it may not be clear that to *use* your macros, the macro call in a scene
should include  srgb (or rgb, as the case may be). Like so:

box{0,1
pigment{srgb RGB2SRGB(<.75,.75,.75>)}
....
}

If it is left out, POV-ray apparently assumes the color to be 'linear' RGB by
default.

I would humbly suggest that you make a few changes to your March 2017 post. ;-)


Post a reply to this message

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