POV-Ray : Newsgroups : povray.advanced-users : rgb vs srgb : Re: rgb vs srgb Server Time
28 Sep 2024 18:56:41 EDT (-0400)
  Re: rgb vs srgb  
From: Zeger Knaepen
Date: 12 Sep 2011 16:15:17
Message: <4e6e6855$1@news.povray.org>
On 12/09/2011 20:55, Warp wrote:
>    The major problem I see with assumed_gamma 1.0 is that designing textures
> becomes more complicated, because textures are usually designed by how they
> should look rather than what their absolute irradiance values are.
>
>    If you are only specifying individual colors, then using 'srgb' takes
> care of that. However, patterns present a problem. Usually you want
> patterns to interpolate linearly from one color to another (with what
> I mean that the interpolation should *look* linear).

Unless I completely misunderstand the workings of gamma, I believe this 
macro should be able to help you:

--- START CODE ---
#declare noWrap=function(x) {max(min(x,1),0)}
#macro pigmentDegamma(Pigment,Gamma)
   #local PigmentFunction=function {pigment {Pigment}}
   #local Result=pigment {
     function {noWrap(PigmentFunction(x,y,z).transmit)}
     pigment_map {
       [0
         average
         pigment_map {
           [1 function {noWrap(PigmentFunction(x,y,z).red)}
             color_map {
               [0 red 0]
               [1 red 1]
             }
             poly_wave Gamma
           ]
           [1 function {noWrap(PigmentFunction(x,y,z).green)}
             color_map {
               [0 green 0]
               [1 green 1]
             }
             poly_wave Gamma
           ]
           [1 function {noWrap(PigmentFunction(x,y,z).blue)}
             color_map {
               [0 blue 0]
               [1 blue 1]
             }
             poly_wave Gamma
           ]
         }
       ]
       [1
         average
         pigment_map {
           [1 function {noWrap(PigmentFunction(x,y,z).red)}
             color_map {
               [0 red 0 transmit 1]
               [1 red 1 transmit 1]
             }
             poly_wave Gamma
           ]
           [1 function {noWrap(PigmentFunction(x,y,z).green)}
             color_map {
               [0 green 0 transmit 1]
               [1 green 1 transmit 1]
             }
             poly_wave Gamma
           ]
           [1 function {noWrap(PigmentFunction(x,y,z).blue)}
             color_map {
               [0 blue 0 transmit 1]
               [1 blue 1 transmit 1]
             }
             poly_wave Gamma
           ]
         }
       ]
     }
   }
   Result
#end
--- END CODE ---

To be used as:

#local Pigment=pigment { [your pigment] }
object {YourObject pigment {pigmentDegamma(Pigment,2.2)}}

Limitations:
- only works with pigments that don't need any surface information (eg: 
aoi will not work)
- "filter" isn't taken into account yet, but that should actually be 
rather easy to fix.. but since I almost never use filter, I didn't 
bother fixing it :)
- only works with pigments with colors in the 0-1 range.  I have no idea 
how easy it would be to fix that, as just dividing the original colors 
before degamma'ing them, and then multiplying them again by that same 
value would not give the correct colors

But still, it might be useful :)

cu!
-- 
ZK


Post a reply to this message

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