POV-Ray : Newsgroups : povray.advanced-users : Gamma and light sources : Re: Gamma and light sources Server Time
25 Apr 2024 16:42:22 EDT (-0400)
  Re: Gamma and light sources  
From: clipka
Date: 2 Sep 2015 09:44:18
Message: <55e6fd32$1@news.povray.org>
Am 31.08.2015 um 17:55 schrieb Mike Horvath:
> Do light sources in POV 3.7 use srgb or rgb?

The question is a bit poorly worded, so instead of trying to guess your
own understanding of that question, I'll try to provide you with
information that should enable you to anwer it yourself:


Light source colours in all versions of POV-Ray are specified in the
very same manner as any other colours in that particular version.

Now first, let's look at what this means for POV-Ray 3.6:

* By default, POV-Ray 3.6 did not do any gamma handling; this can be
interpreted in two ways:

(a) According to the design and implementation, and although this was
certainly unintentional, POV-Ray 3.6 interpreted all colour expressions
as colour coordinates in a linear RGB colour space, expected all input
images to be in that same colour space, and generated output images in
that same colour space. In this sense, POV-Ray 3.6 did everything right,
but colour in- and output were in an uncommon format, a fact that was
entirely unknown to most (if not all) users; as a result, users would
create scenes that did not match what they wanted, and got results they
wouldn't have wanted but, when misinterpreted in the most typical way,
"happened" to look pretty much exactly like what they wanted.

(b) According to the users' experience, it would seem that POV-Ray 3.6
interpreted all colour expressions as colour coordinates in an RGB
colour space gamma pre-corrected for the user's display system, expected
all input images to be in that same colour space, and generated output
images in that same colour space. In this sense, POV-Ray 3.6's colour
handling matched user expectations, but (again entirely unknown to most
users) it got a variety of colour computations outright wrong.

Most (if not all) legacy scenes (POV-Ray 3.6 scenes without explicit
"assumed_gamma") would be written specifying all colours in sRGB
coordinates (or something very close), but using the "rgb" family of
keywords to specify them (the "srgb" keyword wasn't available back then).

* Alternatively, POV-Ray 3.6 already supported the "assumed_gamma"
keyword. Back then, its only effect was on file output, and was a way to
tell POV-Ray whether the above interpretation (a) or (b) was desired (by
setting assumed_gamma to either 1.0 or 2.2), but forcing POV-Ray to
generate output images with properly gamma pre-corrected colours in
either case. (There was also the possibility to choose a value in
between, or even larger or smaller, but I won't go into detail about that.)

Many "semi-legacy" scenes (POV-Ray 3.6 scenes with explicit
"assumed_gamma") would be written specifying all colours in something
somewhat close to sRGB coordinates ("assumed_gamma 2.2"), but using the
"rgb" keyword to specify them, just like in legacy scenes; others would
be written specifying all colours in linear RGB coordinates
("assumed_gamma 1.0"), also using the "rgb" keyword to specify those,
much like modern scenes.


Now let's examine POV-Ray 3.7:

* If you specify "#version 3.6", POV-Ray 3.7's colour handling is
virtually the same as that of POV-Ray 3.6.

* If you specify "#version 3.7", POV-Ray 3.7 defaults to "assumed_gamma
1.0", but other than that there is /still/ no fundamental difference to
the behaviour of POV-Ray 3.6, except that you get some /extensions/ to
complement the "assumed_gamma" mechanism:

- When using the "rgb" family of keywords, the colour expression's
interpretation will /still/ depend on the assumed_gamma setting; using
the "srgb" family of keywords, however, will cause the colour expression
to /always/ be interpreted as a colour coordinate in sRGB space. (This
feature is even available when "#version 3.6" is specified.)

- POV-Ray will no longer expect input image files to be in the same
colour space as colours specified using the "rgb" family of keywords;
instead, POV-Ray will do its best to auto-detect what gamma the image
data is pre-corrected for, and convert the data accordingly. (There's
also a syntax to override the auto-detection.)


It is highly recommended that modern (POV-Ray 3.7) scenes use
"assumed_gamma 1.0", and use the "srgb" family of keywords wherever
colour coordinates in sRGB space are known, while using the "rgb" family
of keywords where it is necessary or desired to supply colour
coordinates in linear colour space.


> Do the colors need to be
> adjusted to the new system? For instance:
> 
> light_source
> {
>     -z * 40960
>     <pow(light_color.red,2.2),pow(light_color.green,2.2),pow(light_color.blue,2.2)>
> 
>     rotate        -x * 60
>     rotate        +y * 45
>     parallel
> }

Presuming that you're trying to migrate a legacy POV-Ray 3.6 scene
without assumed_gamma setting, or trying to migrate a scene with
"assumed_gamma 2.2" to "assumed_gamma 1.0", I recommend that you use the
"srgb" family of keywords in the /definition/ of light_color. If you do
that, there should be no need to perform any color conversions in the
light source definition itself.


Post a reply to this message

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