POV-Ray : Newsgroups : povray.pov4.discussion.general : Gamma correction of input colours/image files : Re: Gamma correction of input colours/image files Server Time
17 May 2024 16:16:13 EDT (-0400)
  Re: Gamma correction of input colours/image files  
From: Ive
Date: 10 Oct 2008 11:55:54
Message: <48ef7b0a@news.povray.org>
scott wrote:

> Currently however, POV assumes all RGB values in the SDL and any RGB 
> values from textures are in linear colour space, and uses them 
> directly in the rendering core.  This often leads to output not being
>  as expected (see numerous posts about "washed out" effect when using
>  image files).
> 

I fully agree with you, but things are even more complicated:
POV "assumes" for all image files to be in linear color space except for
PNG if they contain a gamma chunk. (But POV recognizes *only* PNG gamma
chunks, other colorimetric chunks like the sRGB chunk are ignored.)
This is why I have converted most of my texture image files to PNG by
using a program that does add this gamma chunk, (e.g. some older
versions of Photoshop did not).

I have also used this macro to use JPEG images as textures:

//=========================================================

#declare sRGB_Inv = function(C) {
   select(C-0.04045, C/12.92, pow((C+0.055)/1.055,2.4))
}

#macro sRGB_JpgMap(ImageName)

#local fn = function {
   pigment {image_map {jpeg ImageName interpolate 2}}
}

pigment {
   average
   pigment_map {
    [function {sRGB_Inv(fn(x,y,z).red)}
      color_map {[0 rgb<0,0,0>][1 rgb<3,0,0>]}]
    [function {sRGB_Inv(fn(x,y,z).green)}
      color_map {[0 rgb<0,0,0>][1 rgb<0,3,0>]}]
    [function {sRGB_Inv(fn(x,y,z).blue)}
      color_map {[0 rgb<0,0,0>][1 rgb<0,0,3>]}]
   }
}
#end

// used like:
pigment {
   sRGB_JpgMap("MyTexture.jpg")
}

//=========================================================

works well but the sad thing is: it slows things down because the colors
are transformed at render time.


About the use of assumed_gamma (and @Warp who seems to advocate this):

The major problem when using assumed_gamma with any value not equal to
1.0 is that antialiasing is no longer done in linear color space and so
results in quite poor quality. I will post an illustration to p.b.i.

It is removed from POV 3.7 - and IMO this is a VERY good idea.

And finally quite frankly: this gamma and assumed_gamma issues have been
discussed so many times and still the same old misconceptions reappear -
this makes me think it is meanwhile a kind of urban legend where some
people just insist to *believe* in something.


-Ive


Post a reply to this message

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