POV-Ray : Newsgroups : povray.general : Assumed_gamma and .gray Server Time
29 Mar 2024 04:52:24 EDT (-0400)
  Assumed_gamma and .gray (Message 1 to 10 of 25)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Cousin Ricky
Subject: Assumed_gamma and .gray
Date: 18 Jan 2017 14:39:28
Message: <587fc470$1@news.povray.org>
Does the .gray operator even work properly if assumed_gamma is not 1.0?


Post a reply to this message

From: Bald Eagle
Subject: Re: Assumed_gamma and .gray
Date: 18 Jan 2017 15:10:00
Message: <web.587fcb7830ab893ac437ac910@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> Does the .gray operator even work properly if assumed_gamma is not 1.0?

Oooh.
Resurrecting TWO very long threads in a single post.
Well played.

Your forum Kung-Fu is strong.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Assumed_gamma and .gray
Date: 18 Jan 2017 15:27:07
Message: <587fcf9b@news.povray.org>
On 2017-01-18 04:09 PM (-4), Bald Eagle wrote:
> Resurrecting TWO very long threads in a single post.

I must have missed the thread on .gray.


Post a reply to this message

From: Bald Eagle
Subject: Re: Assumed_gamma and .gray
Date: 18 Jan 2017 16:35:00
Message: <web.587fdead30ab893ac437ac910@news.povray.org>
Cousin Ricky <ric### [at] yahoocom> wrote:
> On 2017-01-18 04:09 PM (-4), Bald Eagle wrote:
> > Resurrecting TWO very long threads in a single post.
>
> I must have missed the thread on .gray.

Now you're just trying to claim a form of extrasensory perception as well.   :D

http://news.povray.org/povray.advanced-users/thread/%3Cweb.577e597b5ff2a8e65e7df57c0%40news.povray.org%3E/?mtop=409379


Post a reply to this message

From: clipka
Subject: Re: Assumed_gamma and .gray
Date: 18 Jan 2017 19:50:04
Message: <58800d3c$1@news.povray.org>
Am 18.01.2017 um 20:42 schrieb Cousin Ricky:
> Does the .gray operator even work properly if assumed_gamma is not 1.0?

Strictly speaking, it does not work properly in _any_ gamma mode. And
less strictly speaking, I am sorry to say that it actually works "/more/
properly" in legacy gamma mode.

The operator is currently implemented as:

    0.297 * .red + 0.589 * .green + 0.114 * .blue

With `assumed_gamma 1.0` this should actually be:

    0.2126 * .red + 0.7152 * .green + 0.0722 * .blue

For any other `assumed_gamma` setting it is difficult to provide a
"correct" formula, as this is an addition, which is always wrong in
non-linear colour space (unless all terms but one are non-zero). One
could redefine ".grey" to mean ".luma", which is a technical term
specifically denoting a weighted sum of the colour channels in a
non-linear RGB colour space, but I'm not aware of any "official" formula
for Luma in sRGB; for the ITU-R BT.709 colour space (`assumed_gamma
bt709`), which uses the same primary colours as sRGB but a slightly
different gamma function, two conflicting formulae have been codified:

CCIR recommendation 601-1 (which does not officially reference BT.709,
but effectively defines the same colour space) suggests a formula that
comes close to the current implementation:

    0.299 * R' + 0.587 * G' + 0.114 * B'

(where R', G' and B' represent the gamma-encoded, i.e. non-linear,
colour values)

On the other hand, ITU-R BT.709 suggests to use the same formula as for
luminance (i.e. linear greyscale):

    0.2126 * R' + 0.7152 * G' + 0.0722 * B'

Since this formula is embedded deep in the bowels of POV-Ray's colour
math, I hadn't found the guts to update it along with the other gamma
stuff back when 3.7.0 came up, as it would have been difficult to
maintain backward compatibility.


Post a reply to this message

From: Bald Eagle
Subject: Re: Assumed_gamma and .gray
Date: 19 Jan 2017 07:50:00
Message: <web.5880b4f930ab893ac437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

[Lots of very interesting technical stuff as usual]

What appears superficially simple and straightforward almost always winds up
being vastly more complex than most people ever think is possible, once someone
dares to open the hood and pick underneath at the actual inner workings of a
thing.

> Since this formula is embedded deep in the bowels of POV-Ray's colour
> math, I hadn't found the guts to update it along with the other gamma
> stuff back when 3.7.0 came up, as it would have been difficult to
> maintain backward compatibility.

Ah... that backwards-facing stance has always been a trammel on humanity.

Just out of curiosity, isn't this the sort of thing the #version statement is
supposed to handle?
I (probably naively and ignorantly) thought it was supposed to do something
like:
#if (that version)
     Do_It (that way)
#else
     Do_It (this way)
#end

(I understand that such a manner of handling things might be extraordinarily
difficult to get to 'reach' that deeply into the structure of the code.)


Post a reply to this message

From: clipka
Subject: Re: Assumed_gamma and .gray
Date: 19 Jan 2017 09:48:28
Message: <5880d1bc$1@news.povray.org>
Am 19.01.2017 um 13:45 schrieb Bald Eagle:
> clipka <ano### [at] anonymousorg> wrote:
> 
> [Lots of very interesting technical stuff as usual]
> 
> What appears superficially simple and straightforward almost always winds up
> being vastly more complex than most people ever think is possible, once someone
> dares to open the hood and pick underneath at the actual inner workings of a
> thing.

I hope I don't scare people away by showing the gory guts of POV-Ray ;)

>> Since this formula is embedded deep in the bowels of POV-Ray's colour
>> math, I hadn't found the guts to update it along with the other gamma
>> stuff back when 3.7.0 came up, as it would have been difficult to
>> maintain backward compatibility.
> 
> Ah... that backwards-facing stance has always been a trammel on humanity.
> 
> Just out of curiosity, isn't this the sort of thing the #version statement is
> supposed to handle?
> I (probably naively and ignorantly) thought it was supposed to do something
> like:
> #if (that version)
>      Do_It (that way)
> #else
>      Do_It (this way)
> #end
> 
> (I understand that such a manner of handling things might be extraordinarily
> difficult to get to 'reach' that deeply into the structure of the code.)

Theoretically, that's /exactly/ how it should work.

But `.grey` is only one of various places where greyscale values are
computed, and I would want to make sure all of them are handled in a
consistent manner. That /could/ be achieved by placing this "if...
else..." construct right into the function designed to compute this
stuff, but that would require making this component of POV-Ray aware of
the user's `#version` choice. Not exactly the ideal thing to do when the
goal is to make the application more modular.

Alternatively, the goal could be achieved by adding a corresponding
"if... else..." construct to each place where greyscale is computed, but
that would require identifying all such places, and then making /them/
aware of the user's `#version` choice if they aren't already.

Back when 3.7.0 was about to be released, I wasn't prepared to tackle
either of these approaches.

Now I guess I would be, but as this would imply a change in default
behaviour of a very common feature for the "assumed_gamma 1.0" mode, I
don't think the transition from 3.7.0 to 3.7.1 is the right time to do
it. Even if a simple "#version" statement would fix it, I think such a
change might be too much of a surprise for the average user, so I prefer
to postpone it to a bigger version step, possibly 3.7 to 3.8.


Post a reply to this message

From: Mr
Subject: Re: Assumed_gamma and .gray
Date: 19 Jan 2017 11:05:00
Message: <web.5880e38530ab893a16086ed00@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 18.01.2017 um 20:42 schrieb Cousin Ricky:
> Strictly speaking, it does not work properly in _any_ gamma mode. And
> [...]I hope I don't scare people away by showing the gory guts of POV-Ray ;)


Well we actually had to use .grey for texture influences in the Blender
exporter.

along with the finish map trick so that a pattern can be used in many places
once declared.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Assumed_gamma and .gray
Date: 19 Jan 2017 23:32:15
Message: <588192cf@news.povray.org>
On 2017-01-19 10:48 AM (-4), clipka wrote:
> [snip approaches to fixing gory guts of POV-Ray]
>
> Back when 3.7.0 was about to be released, I wasn't prepared to tackle
> either of these approaches.
>
> Now I guess I would be, but as this would imply a change in default
> behaviour of a very common feature for the "assumed_gamma 1.0" mode, I
> don't think the transition from 3.7.0 to 3.7.1 is the right time to do
> it. Even if a simple "#version" statement would fix it, I think such a
> change might be too much of a surprise for the average user, so I prefer
> to postpone it to a bigger version step, possibly 3.7 to 3.8.

I guess it's time (for those of us who use the One True assumed_gamma) 
to add this function to our personal libraries until this issue gets 
sorted out:

#macro DotGray (Color)
   #local C = color Color;
   (0.2126 * C.red + 0.7152 * C.green + 0.0722 * C.blue) // ITU-R BT.709
#end


Post a reply to this message

From: Thomas de Groot
Subject: Re: Assumed_gamma and .gray
Date: 20 Jan 2017 02:54:03
Message: <5881c21b@news.povray.org>
On 20-1-2017 5:35, Cousin Ricky wrote:
> I guess it's time (for those of us who use the One True assumed_gamma)
> to add this function to our personal libraries until this issue gets
> sorted out:
>
> #macro DotGray (Color)
>   #local C = color Color;
>   (0.2126 * C.red + 0.7152 * C.green + 0.0722 * C.blue) // ITU-R BT.709
> #end
>

[scribbles with pencil on a greasy scrap of wrapping paper, and tacks it 
to an overweight folder]

Done!

-- 
Thomas


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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