POV-Ray : Newsgroups : povray.binaries.images : Stock colors and assumed_gamma 1 in POV-Ray 3.6 Server Time
19 May 2024 23:34:04 EDT (-0400)
  Stock colors and assumed_gamma 1 in POV-Ray 3.6 (Message 48 to 57 of 77)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Ive
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 27 Oct 2020 17:35:51
Message: <5f9892b7$1@news.povray.org>
Am 10/18/2020 um 23:22 schrieb Bald Eagle:
> 
> The new tone-adjusting formulas are:
> 
> #declare SRGB_Encode = function (C, M) {
>   select (C-0.0031308, C*12.92*M, C*12.92*M, (1.055 * pow (C, 1/2.4) - 0.055)*M)
> }
> 
> #declare SRGB_Decode = function (C, M) {
>   select (C-0.040449936, C/12.92, pow ((C+0.055)/1.055, 2.4)*M)
> }
> 
> using M as a multiplier.  Looks like it works correctly
 >


Nope. Both functions are wrong far all M <> 1.0!

If you do not already see this by looking at the formulas just check it: 
Use SRGB_Encode for any value of C and then the result for SRGB_Decode. 
This should give the original value of C.


The correct functions would be

#declare SRGB_Encode = function (C, M) {
  select (C*M-0.0031308, C*12.92*M, C*12.92*M, (1.055 * pow (C*M, 1/2.4) 
- 0.055))
}

#declare SRGB_Decode = function (C, M) {
  select (C-0.040449936, C/12.92, pow ((C+0.055)/1.055, 2.4))*M
}


It worries me for this NG that stuff like this stays uncorrected for 
over 10 days.

-Ive


Post a reply to this message

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 27 Oct 2020 19:40:01
Message: <web.5f98af8b76c60ba8d98418910@news.povray.org>
Ive <ive### [at] lilysoftorg> wrote:

>
> The correct functions would be
>
> #declare SRGB_Encode = function (C, M) {
>   select (C*M-0.0031308, C*12.92*M, C*12.92*M, (1.055 * pow (C*M, 1/2.4)
> - 0.055))
> }
>
> #declare SRGB_Decode = function (C, M) {
>   select (C-0.040449936, C/12.92, pow ((C+0.055)/1.055, 2.4))*M
> }
>
> It worries me for this NG that stuff like this stays uncorrected for
> over 10 days.
>

Well, see? It did get corrected :-) (Not that I would know which is which,
mathematically speaking; functions are sometimes a 'black box' to me.) I like to
think that the newsgroups are *eventually* self-correcting, like after-the-fact
letters to a scientific publication.

I hate to admit that I have not yet tried Bald Eagle's functions; perhaps a
purely visual test would have shown that something might be amiss. [Sorry, B.E.,
I've been busy with other coding.]

He did say, ..."Perhaps it's not "right", but it's the way I envisioned its
usage."

In any case, thanks for the update.


Post a reply to this message

From: Kenneth
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 27 Oct 2020 21:05:01
Message: <web.5f98c36776c60ba8d98418910@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> Ive <ive### [at] lilysoftorg> wrote:
>
> >
> > The correct functions would be
> > [snip]

Just to clarify, in my own mind, some things about the use of these functions
(because I'm currently working on an all-inclusive test scene about this stuff):

When using assumed_gamma 1.0, and in POV-ray's preview render:

If I want to *multiply* an RGB color,  rgb 0.7*<.3,.5,.7> would be OK to do.

But if I want to multiply an SRGB color,  srgb 0.7*<.3,.5,.7> would NOT be the
correct way to do it, to get the 'expected' color result (if I understand some
of Clipka's older remarks); I would instead need to use a somewhat different
multiplication scheme. Is that what these 'multiplication functions' are for--
the way to properly 'multiply' an SRGB color?

Or is   srgb 0.7*<.3,.5,.7>  perfectly OK by itself?

Or am I way off base as to what the functions themselves are meant for?


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 27 Oct 2020 21:45:00
Message: <web.5f98ccac76c60ba81f9dae300@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Kenneth" <kdw### [at] gmailcom> wrote:
> > Ive <ive### [at] lilysoftorg> wrote:

> > > The correct functions would be
> > > [snip]

I don't have my initial experiments on hand, and I may have coded something
equivalent, but I will have to graph what you have to see for sure.

> If I want to *multiply* an RGB color,  rgb 0.7*<.3,.5,.7> would be OK to do.

Yes.  I do this all the time, and is what clipka mentioned was fine.

> But if I want to multiply an SRGB color,  srgb 0.7*<.3,.5,.7> would NOT be the
> correct way to do it,

Right, which is what he was telling me at the time.

> to get the 'expected' color result (if I understand some
> of Clipka's older remarks); I would instead need to use a somewhat different
> multiplication scheme. Is that what these 'multiplication functions' are for--
> the way to properly 'multiply' an SRGB color?

Well, let's say that's the _goal_.  My functions are wrong, I'm assuming I've's
are correct.
I _should_ have done what I normally do to self-check, which is convert an rgb
color to srgb, and then use the srgb to rgb conversion to convert it back, and
get the original value.

> Or is   srgb 0.7*<.3,.5,.7>  perfectly OK by itself?

it is not.  When you invoke the srgb keyword, it "moves" you from a linear
interpolation to a non-linear interpolation.  And you have to "do the
multiplication" _inside_ of that nonlinear "space".  I guess maybe you can see
it as moving by a factor M along the curve, rather than along the line.

> Or am I way off base as to what the functions themselves are meant for?

I think you get the general gist of it, if not the explicit details.
I can't remember what time I worked this out - but It may have been a bit late
and it seemed to be what I was shooting for rather than the technically correct
rgb to srgb conversion and multiplication.   But I probably should have stated
that AND provided a proper way for comparison as well.



And to be fair - we've had formula errors lurking in the source for ~25 years
without anyone noticing.... so...

;)


Thanks, Ive, for catching this and pointing it out.
I'll have to go back to it again and not be so lax in double-triple checking,
back-checking, and graphing the results.

I of course would love to hear any commentary you might have on mapping the
lighting and image and pigment curves to each other....


Post a reply to this message

From: Ive
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 28 Oct 2020 00:03:20
Message: <5f98ed88$1@news.povray.org>
Am 10/28/2020 um 2:03 schrieb Kenneth:
> 
> When using assumed_gamma 1.0, and in POV-ray's preview render:
> 

When using anything but assumed_gamma 1.0 it makes no sense to use the 
srgb keyword anyway.

> If I want to *multiply* an RGB color,  rgb 0.7*<.3,.5,.7> would be OK to do.
> 
Sure.

> But if I want to multiply an SRGB color,  srgb 0.7*<.3,.5,.7> would NOT be the
> correct way to do it, to get the 'expected' color result (if I understand some
> of Clipka's older remarks); I would instead need to use a somewhat different
> multiplication scheme. Is that what these 'multiplication functions' are for--
> the way to properly 'multiply' an SRGB color?
> 
> Or is   srgb 0.7*<.3,.5,.7>  perfectly OK by itself?
> 
No it isn't. When using the keyword "srgb" you just tell POV-Ray that 
the following color term is "sRGB gamma encoded".
Multiplying any non linear color value does not only change the 
brightness but also the hue - and is therefor plain wrong.

I haven't used POV-Ray in years and never used the srgb keyword in my 
whole live (I switched to Adobe RGB a long time ago) so I'm not sure if 
it will swallow this syntax but at least you should get the idea...

#declare C = (srgb <.3,.5,.7>) * 0.7;

> Or am I way off base as to what the functions themselves are meant for?
> 

Yes, I guess this is what BE meant it for even if he called it 
"tone-adjusting" while in fact it is a brightness or intensity adjusting.



...and BTW I just stumbeled over your bold statement

[quote]
simply to get the color I 'visually' expect as
opposed to 'linear' rgb colors that are intrinsically washed-out in an
assumed_gamma 1.0 environment.
[/quote]

I used from the very start (more then 2 decades ago, I guess 3.0 at the 
time) assumed_gamma 1.0 (I already had some experience in the field of 
image processing) and no image I ever created suffered from a washed-out 
look. Some early images of mine did look ugly because my own bad choice 
of colors or bad arrangement of objects but these are no gamma related 
problems ;)


BTW during the early phase of POV-Ray 3.7 alpha development I had this
on my webpage:

https://www.lilysoft.org/Stuff/gamma.html

thankfully Christoph did make all the described workarounds obsolete as 
he improved the image file handling and also implemented an image file 
related gamma keyword as I did suggest there, so after the 3.7 release I 
removed any direct link from my side.

And BTW-2 your cityscape looks phantastic and things like this are still 
the strength of POV-Ray even when it has sadly fallen far behind as a 
render engine.


-Ive


Post a reply to this message

From: Ive
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 28 Oct 2020 00:49:16
Message: <5f98f84c$1@news.povray.org>
Am 10/28/2020 um 2:43 schrieb Bald Eagle:
> 
> And to be fair - we've had formula errors lurking in the source for ~25 years
> without anyone noticing.... so...
> 
> ;)
> 

I hope you did not get me wrong. I was not criticizing you - having been 
a programmer once I know very well how easily it happens, but I think in 
former times, mistakes here were quickly spotted. But maybe I'm just 
idealizing the past, like old men often do...

To me it was obvious by just looking at the formula that the linear part 
of the function is no longer the tangent to the exponential part for any 
M <> 1. This did surprise me because you already did switch away from 
the official sRGB gamma correction formula that also has a very small 
gap and makes no perfect tangent. Something that did annoy me since the 
very first draft for sRGB by HP and Microsoft.

> 
> Thanks, Ive, for catching this and pointing it out.
> I'll have to go back to it again and not be so lax in double-triple checking,
> back-checking, and graphing the results.

No problem, take your time.

> 
> I of course would love to hear any commentary you might have on mapping the
> lighting and image and pigment curves to each other....
> 

Well, now I have read through the whole thread. What a mess. There are 
so many false statements, combined with completely correct statements 
and - as usually - the worst ones: almost true statements.
And then are the things that are simply not relevant anymore (like the 
whole discussion with Warp - Clipka expanded the color_map syntax so 
that none of the complains is still valid).
So frankly, looking back at the whole thread, I really don't know where 
to begin. But if you have any concrete questions, just ask away...

-Ive


-


Post a reply to this message

From: Thomas de Groot
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 28 Oct 2020 03:54:40
Message: <5f9923c0$1@news.povray.org>
Op 28/10/2020 om 05:03 schreef Ive:
> Am 10/28/2020 um 2:03 schrieb Kenneth:
>>

>>
> No it isn't. When using the keyword "srgb" you just tell POV-Ray that 
> the following color term is "sRGB gamma encoded".
> Multiplying any non linear color value does not only change the 
> brightness but also the hue - and is therefor plain wrong.
> 
> I haven't used POV-Ray in years and never used the srgb keyword in my 
> whole live (I switched to Adobe RGB a long time ago) so I'm not sure if 
> it will swallow this syntax but at least you should get the idea...
> 
> #declare C = (srgb <.3,.5,.7>) * 0.7;
> 

Maybe you remember the Bald Eagle / Clipka discussion in 
http://news.povray.org/povray.advanced-users/thread/%3C57894ece%241%40news.povray.org%3E/

I digested that at the time in the attached macro. I think (?) this is 
(part of) this answer...


-- 
Thomas


Post a reply to this message


Attachments:
Download 'utf-8' (8 KB)

From: Ive
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 28 Oct 2020 05:33:12
Message: <5f993ad8$1@news.povray.org>
Am 10/28/2020 um 8:54 schrieb Thomas de Groot:
> 
> Maybe you remember the Bald Eagle / Clipka discussion in 
>
http://news.povray.org/povray.advanced-users/thread/%3C57894ece%241%40news.povray.org%3E/

> 
I admire your memory. Especially not just remembering it - but also *where*.

But no I don't think I did read this thread, otherwise I would have been 
tempted to remark that my silly demo scene "cyndi cubes" demonstrates 
the usage of the macros from my file CIE_tools (both part of the 
Lightsys package) and these would be much more powerful (e.g. would also
be able to compensate for whitepoint errors) than Clipka's suggestions.

Which reminds me, these files were written back in 2003, long before 
Christoph even joint the POV-Ray community and meanwhile he already left 
- people come and go and doesn't time fly by?

-Ive


Post a reply to this message

From: Bald Eagle
Subject: Re: Stock colors and assumed_gamma 1 in POV-Ray 3.6
Date: 28 Oct 2020 07:10:00
Message: <web.5f99507e76c60ba81f9dae300@news.povray.org>
Ive <ive### [at] lilysoftorg> wrote:

> I hope you did not get me wrong. I was not criticizing you - having been
> a programmer once I know very well how easily it happens, but I think in
> former times, mistakes here were quickly spotted. But maybe I'm just
> idealizing the past, like old men often do...

Nope - it's a simple matter of traffic x expertise.
Traffic here is down, and some of us are not yet at the expertise level in some
of the fields where we can just glance at something and the errors and
misconceptions are painfully obvious.
But some of us old men are stubborn, as we often are, and just keep on throwing
ourselves at that learning curve.   :)

> To me it was obvious by just looking at the formula that the linear part
> of the function is no longer the tangent to the exponential part for any
> M <> 1. This did surprise me because you already did switch away from
> the official sRGB gamma correction formula that also has a very small
> gap and makes no perfect tangent. Something that did annoy me since the
> very first draft for sRGB by HP and Microsoft.

Excellent.  A recondite man of great experience.
(You should drop in more often to watch the sht show  ;) )

The intense friction between the theoreticians and empirical experimentalists
and engineers is likely to be eternal  ;)


> Well, now I have read through the whole thread. What a mess. There are
> so many false statements, combined with completely correct statements
> and - as usually - the worst ones: almost true statements.

Oh yes - those are especially naughty.
If you ever wonder why the world we live in is the way it is....


> But if you have any concrete questions, just ask away...

I'll try, but I might just be providing examples of my present level of
[mis]understanding.
(And I'm ok with spreadsheets or graphs or papers to set me on the right path.)

Hmmm.
Conversion formulas aside, what at any given moment are we working with?

When everything is expressed in pigment {rgb <r, g, b,>} at assumed_gammma 1.0,
everything seems pretty straightforward.

But let's say someone borrows a nice texture that has srgb keywords sprinkled
throughout its declaration.  The color that pigment color values that get
"exposed" to the other elements in the scene are still just - rgb, correct?

Two things which seem pretty unclear are the effect of assumed_gamma srgb,
and/or a light source defined as srgb.  I can conceive the light source as just
being the rgb end result of the srgb conversion formula, like the texture
example, but just checking.
But assumed gamma must affect the whole scene - presumably by doing all of the
color calculations in "srgb color space".  Which with my present understanding,
and peeks into the source code, lead me to speculate that multiplying a pigment
color by a light source color gets a whole lot more complicated.

And reflections.   Metallic reflections.

Does one use srgb for all colors in assumed_gamma srgb scenes or rgb?

What's the proper way to instantiate image_maps that may be encoded by libraries
with in-built gamma handling precorrections?

I guess the concern here with many of my examples / implied questions is the
user trying to do something with srgb, and the software then doing a second
conversion - or the user NOT doing a conversion where needed and winding up not
using the color values needed for consistency with the rest of the scene, or
something getting corrected by the software in the opposite direction because a
user wasn't aware of a required precorrection.

If ANY of that makes any sense.


Post a reply to this message

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

>
> Does one use srgb for all colors in assumed_gamma srgb scenes or rgb?
>

Ah! That's *one* thing that I can answer, from my test scene so far: With
assumed_gamma srgb, the color types don't matter. Both rgb and srgb produce the
exact same result-- srgb colors. Exactly exact, not like srgb colors in
2.2-gamma space, with that *slight* difference we saw. I think Cousin Ricky(?)
or JR (?)mentioned it previously, somewhere in this messy thread, which I didn't
'process' at the time.  ;-)


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.