POV-Ray : Newsgroups : povray.binaries.images : Stock colors and assumed_gamma 1 in POV-Ray 3.6 Server Time
28 Mar 2024 17:58:39 EDT (-0400)
  Stock colors and assumed_gamma 1 in POV-Ray 3.6 (Message 11 to 20 of 77)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
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

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 16 Oct 2020 09:05:08
Message: <web.5f89995a76c60ba8d98418910@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

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

Hmm, a dubious distinction :-0

OK, you asked for it. But gamma is such a tricky and complex subject that I may
come across as either sounding like a genius, or sounding  like an idiot. :P
There are aspects of this business that still puzzle me, and I have left out a
lot of extraneous details; but this is how I see it so far. (And this is the
SHORT-version, ha.) I await judgement ;-)

I'll concentrate on the RGB-to-SRGB conversion formula. I 'borrowed' a diagram
from the NVIDIA article and posted it here, to help explain things (it should be
on the Wikipedia page too, which would go a long way to explain the actual
intended use of the equations there.)

In a nutshell:

Our computers/monitors have an intrinsic built-in  'gamma' of generally around
2.2. That computer gamma is the curved "CRT gamma line" in the diagram. The
straight line represents color values fed to the display.

When we save an image in POV-ray (i.e., the rendered image), it contains
*linear* image data, but with a gamma chunk to tell the computer what to do with
it-- either 2.2 (automatic for older versions) or, for v3.7xx-3.8xx, either 2.2
or srgb by way of the newer File_Gamma keyword in our .ini file.  (These gamma
chunks are possibly the 'inverse' of the values, but that's too much technical
detail for this discussion.)

The RGB-to-SRGB conversion equation as-is on the Wikipedia page (and elsewhere)
refers to this image-ENCODING gamma-- the gamma chunk-- when an image is finally
sent to the computer/monitor for display. The surprise (as regards POV-ray's use
of the SRGB keyword for colors) is that the equation actually 'brightens'  the
image values, to prepare them for the counter- 'gamma-bending' by the computer's
intrinsic 2.2 gamma-- so that their final perceptual appearance is once again
along  the straight line. These gamma-encoded values are represented by the
dashed line in the diagram.

This is what the equation itself is meant to do-- it's for gamma-ENCODING an
image.  But that's the *opposite* of what we want it to do **within POV-ray**;
we want to take a too-bright linear RGB color there -- say, 50% gray, which
*appears* too bright in our assumed_gamma 1.0 world-- and *darken* it to look
perceptually correct in our preview render.

So, the 'opposite' SRGB-to-RGB equation on the page is the one to use, even
though that seems counter-intuitive.

Using POV-ray's assumed_gamma 1.0 in a scene is like having a self-contained
'box' in the computer with its own 'linear gamma atmosphere' of 1.0, sealed off
from the computer's gamma 2.2  environment. We work within that box, visually
and computationally.  Now, because *linear* RGB color values in such an
environment look kind of washed-out to our own eyes, we need a way within
POV-ray to mimic the surrounding gamma-2.2 world-- not by using assumed_gamma
2.2 there (for subtle computational reasons), but with SRGB colors. Of course,
you *could* use linear colors along with assumed_gamma 1.0, and simply tweak the
visual results to your liking in the preview-- using 22% gray instead of 50% so
that it 'looks' correct as middle-gray-- but most if not all other image-making
programs don't operate in a gamma 1.0 environment like that; we are simply used
to the visual preview results of, say, 50% linear gray automatically looking
like 22%. Working with colors is just easier this way-- we can specify srgb and
'get' 22%, which is perceptually midway between black and white.

For older versions of POV-ray without the srgb color keyword, setting
assumed_gamma to 2.2 was an expedient way around this, but with its own mess of
subtle problems as to internal computations.


Post a reply to this message


Attachments:
Download 'gamma_slopes_image.jpg' (56 KB)

Preview of image 'gamma_slopes_image.jpg'
gamma_slopes_image.jpg


 

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

> Hmm, a dubious distinction :-0
>
> OK, you asked for it. But gamma is such a tricky and complex subject that I may
> come across as either sounding like a genius, or sounding  like an idiot.

I think gamma is one of things that _seems_ complex simply because there's no
visual and interactive roadmap.

I've had to memorize things, and use or teach subjects that people's popular
perception is that they are "lofty" or "complicated" - yet these same people
know THOUSANDS of song lyrics, driving directions, and play very layered,
conditional video and other games all the time.

In the same way that the graph shows arrows representing conversions between the
different curves, I'd like it if we could have a collection macros that do the
same thing - with a switch to turn on some text output to the debug stream
describing the inputs and results.  "Converting linear rgb <r, g, b> to sRGB
<sr, sg, sb>..."   or some such thing.

and if everything were expressed as function{}s, then it would be easy to have a
macro that creates a graph like you attached.

I would also like to have a way to do what clipka was cautioning me about -
where a palette of srgb colors could be lightened or darkened using a
multiplier, and the math would be correct to do it in the proper color space.

Because we've all been around the block enough times to _know_ that this kind of
thing is going to crop up again and again and again.

I think you invested a few well-spent hours familiarizing yourself with the
topic, and now it's time to "write it down" in a way that exactly matches how
POV-Ray handles the conversion, and is accessible in a way that users don't have
to reinvent the wheel in order to ascend that learning curve.

I have the POV-planet project, the Bezier stuff, the quilted pattern all
swirling around - but I can help out with getting the function {} structure and
syntax right, and maybe dig up POV-Ray's source code to see exactly what's going
on there.

Good work, Sir.
It's a pleasure to have you back   :)


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 16 Oct 2020 17:45:01
Message: <web.5f8a13a376c60ba81f9dae300@news.povray.org>
It seems to me that the color conversion code is in
source/base/image/colourspace.cpp


Post a reply to this message

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

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