|
|
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
|
|