POV-Ray : Newsgroups : povray.binaries.images : Stock colors and assumed_gamma 1 in POV-Ray 3.6 Server Time
5 Jul 2024 14:53:14 EDT (-0400)
  Stock colors and assumed_gamma 1 in POV-Ray 3.6 (Message 8 to 17 of 77)  
<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 14 Oct 2020 10:50:00
Message: <web.5f870fa276c60ba8d98418910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
>
> >
> > 'Fixing' your two macros is a simple matter-- just
> > rename RGB2SRGB(C_linear) as SRGB2RGB(C_exponential), ha. And vice-versa.
>
> Well, I guess the macros do need a bit more than that in their code... only to
> have consistency among the names of their internal variables. Minor work.
>

I had some free time, so I 're-packaged' the macros for you, with all the
(minor) changes, and the switch of the macro names. All should work well, but
re-test them for any last-minute typos I may have made.


Post a reply to this message


Attachments:
Download 'color_conversion_macros_redone.txt' (3 KB)

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 14 Oct 2020 12:15:01
Message: <web.5f87236d76c60ba8d98418910@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
>
> So I wrote a scene to render some of the grays with different gamma
> configurations under different POV-Ray versions, then sampled the output
> images and created montages with the sampled values...

Getting back to your original post here, about the slight discrepancies in color
values among the various versions of POV-ray:

I did some *basic* tests, solely in v3.8, using a simple pigment plus the
eval_pigment{...) macro, and I still get slight discrepancies in compared color
values. It somehow comes from the use of  srgb  vs.  rgb  in a color, AND on the
assumed_gamma of the scene.

#declare PIG_C = pigment{rgb <.75,.75,.75>} // CHANGE this from srgb to rgb

#debug concat("\n","PIGMENT_C evaluation = <",vstr(3,eval_pigment(PIG_C,
<.2,.2,.2>),", ",0,6),">","\n\n")

The various results using different assumed_gamma values:
--- With assumed_gamma 1.0:
1) using srgb: eval_pigment = <0.522522,0.522522,0.522522> // correct
2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000> // correct
--- With assumed_gamma 2.2:
// 1) using srgb: eval_pigment = <0.744501,0.744501,0.744501> // ??
// 2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000>
--- with assumed_gamma srgb:
// 1) using srgb: eval_pigment = <0.750000,0.750000,0.750000>
// 2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000>

Under assumed_gamma 1.0, the evaluated values are correct. But under
assumed_gamma 2.2, the result with srgb is *slightly* off from the original
value. I have no idea why. (I would have thought that those two values would be
MUCH different, like under assumed_gamma 1.0).


Post a reply to this message

From: Cousin Ricky
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 14 Oct 2020 20:40:00
Message: <web.5f8799f076c60ba860e0cc3d0@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> The various results using different assumed_gamma values:
> --- With assumed_gamma 1.0:
> 1) using srgb: eval_pigment = <0.522522,0.522522,0.522522> // correct
> 2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000> // correct
> --- With assumed_gamma 2.2:
> // 1) using srgb: eval_pigment = <0.744501,0.744501,0.744501> // ??
> // 2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000>
> --- with assumed_gamma srgb:
> // 1) using srgb: eval_pigment = <0.750000,0.750000,0.750000>
> // 2) using rgb:  eval_pigment = <0.750000,0.750000,0.750000>
>
> Under assumed_gamma 1.0, the evaluated values are correct. But under
> assumed_gamma 2.2, the result with srgb is *slightly* off from the original
> value. I have no idea why. (I would have thought that those two values would be
> MUCH different, like under assumed_gamma 1.0).

The srgb keyword always returns a color that *looks* the same across all
assumed_gamma settings.  To take your example, srgb 0.75 will *look* the same
whether your scene uses assumed_gamma 1, assumed_gamma 2.2, or assumed_gamma
srgb.  But this implies that, internally, it will evaluate to different rgb
values depending on the assumed_gamma setting.

When you use assumed_gamma srgb, the scene's nonlinearity aligns with the color
definition, which is why rgb and srgb return the same value.  And since sRGB is
close to gamma 2.2, rgb and srgb return close, but not identical, values under
assumed_gamma 2.2.


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 14 Oct 2020 21:40:01
Message: <web.5f87a83776c60ba81f9dae300@news.povray.org>
"Cousin Ricky" <rickysttATyahooDOTcom> wrote:

> When you use assumed_gamma srgb, the scene's nonlinearity aligns with the color
> definition, which is why rgb and srgb return the same value.  And since sRGB is
> close to gamma 2.2, rgb and srgb return close, but not identical, values under
> assumed_gamma 2.2.

"Unlike most other RGB color spaces, the sRGB gamma cannot be expressed as a
single numerical value. The overall gamma is approximately 2.2, consisting of a
linear (gamma 1.0) section near black, and a non-linear section elsewhere
involving a 2.4 exponent and a gamma (slope of log output versus log input)
changing from 1.0 through about 2.3. The purpose of the linear section is so the
curve does not have an infinite slope at zero, which could cause numerical
problems."

https://en.wikipedia.org/wiki/SRGB

So there needs to be a function(_r, _g, _b) {} with a select () statement in it.


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 14 Oct 2020 22:25:00
Message: <web.5f87b2cb76c60ba81f9dae300@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> So there needs to be a function(_r, _g, _b) {} with a select () statement in it.

Which of course you have, (duh) but what I'm thinking is that the specific way
you implemented the sRGB standard might be one of the slightly different ways
mentioned, compared to how it's actually implemented in POV-Ray.

So, I'd either play with some of the gobbledygook in the wikipedia page, or look
at what Mike Horvath has done
https://github.com/mjhorvath/Mike-Wikipedia-Illustrations
(the whole zip is like 78MB) to see what sorts of color conversion functions he
uses.

because I'm hoping that since he worked closely with clipka on this, that it's
"as-per-POV-Ray"

or we need to dig up the part in the POV-Ray source code where rgb gets
converted to sRGB to see exactly what gets done.

But I got zippo-zero done today, so now I'm going to bed.  :D

Super nice work with the updating - I'm glad you tracked down that Wikipedia was
_wrong_   :O   That's actually been bothering me this whole time, whenever I'd
hearken back to why I wrote them in the first place.   Makes me feel better to
know that I was doing the right thing but with wrong information.  :)

THANK YOU

Strange that neither Mike nor Christoph picked up on it - but maybe they
mentioned it in one of his scene development threads?


Post a reply to this message

From: Ash Holsenback
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 15 Oct 2020 05:02:52
Message: <5f88103c$1@news.povray.org>
On 10/14/20 10:24 PM, Bald Eagle wrote:
> Super nice work with the updating - I'm glad you tracked down that Wikipedia was
> _wrong_   :O   That's actually been bothering me this whole time, whenever I'd
> hearken back to why I wrote them in the first place.   Makes me feel better to
> know that I was doing the right thing but with wrong information.  :)

would one of you guys PLEASE be a little bit more specific about what is 
wrong on wiki... several of you are so darn verbose my eyes have just 
glazed over


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 15 Oct 2020 06:45:00
Message: <web.5f8827f076c60ba81f9dae300@news.povray.org>
Ash Holsenback <no### [at] spamcom> wrote:

> would one of you guys PLEASE be a little bit more specific about what is
> wrong on wiki... several of you are so darn verbose my eyes have just
> glazed over

There once was a man named Jim
My verbosity was getting to him
So instead of Wikipedia
I rendered some media {}
And sent a pretty picture to him

:)   <curtsy>

Don't take this as the final answer, but what I THINK Kenneth found is where it
says

"These linear RGB values are not the final result; gamma correction must still
be applied. The following formula transforms the linear values into sRGB:"

and then immediately following those formulae

The reverse transformation
"Again the sRGB component values Rsrgb, Gsrgb, Bsrgb are in the range 0 to 1.
(Values in the range of 0 to 255 can simply be divided by 255.0)."

should be reversed.


But I haven't re-wrapped my head around the whole gamma thing _again_....

my macros originated from this discussion:

http://news.povray.org/58cb2917%241%40news.povray.org


Post a reply to this message

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 15 Oct 2020 13:10:01
Message: <web.5f88817476c60ba8d98418910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > Hi Kenneth - this is something that I was concerned about, tried to
> > address, and IIRC, did it backwards.
> >
>
> 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...
>
Well, I never like to base my ideas on a single source of information, so I
looked at other web sources that have these 'color conversion' equations-- and
ALL the sources I've seen match the order of the equations in Wikipedia.  So I'm
obviously wrong about the two equations being 'backward' there. I gave this a
lot of thought, and realized that it's our *use* of those equations **in
POV-ray** that makes them seem so. To really explain why would take paragraphs,
and I'm still wrapping my brain around it. And I might put Ash to sleep... :-P

But the re-edited macros are still correct for their use in POV-ray... a
consequence of this 'new thinking'.

This NVIDIA article really opened my eyes to the correct way of visualizing the
situation, although it may not be immediately obvious...

https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear


Post a reply to this message

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 15 Oct 2020 13:25:01
Message: <web.5f8885a476c60ba8d98418910@news.povray.org>
Ash Holsenback <no### [at] spamcom> wrote:

>
> would one of you guys PLEASE be a little bit more specific about what is
> wrong on wiki... several of you are so darn verbose my eyes have just
> glazed over

The Wikipedia page about "sRGB" has two nasty-looking math equations for
converting 'linear' RGB colors (like in colors.inc) into SRGB colors, and vice
versa. But Bald Eagle and I thought that the equations were 'reversed' there--
because the math *results* of each equation had the opposite effect of what we
wanted them to do in POV-ray. But the equations ARE correct-- it's just that
their intended use *in POV-ray* was the opposite of what the wiki article is
actually describing. That's hard to explain without a lengthy essay on the
subject ;-)


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 15 Oct 2020 14:40:01
Message: <web.5f88973876c60ba81f9dae300@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

> But the equations ARE correct-- it's just that
> their intended use *in POV-ray* was the opposite of what the wiki article is
> actually describing. That's hard to explain without a lengthy essay on the
> subject ;-)

The POV-Ray Essay Commission will now come to order.
{reverberating gavel sound, muffled coughing and shuffling}

Kenneth Walker has been nominated to author The Essay on sRGB conversion
formulas.

Do I hear a second?
"Second!"

All those in favor of Kenneth writing a lengthy essay say Aye...
"Aye!"     "Aye!"     "Aye!"     "Aye!"     "Aye!"     "Aye!"     "Aye!"

The Aye's have it.

Kenneth Walker is now appointed as the Maintainer of the Gamma, and The
Commission anxiously awaits his proffered essay....

:P


Post a reply to this message

<<< Previous 7 Messages Goto Latest 10 Messages Next 10 Messages >>>

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