GIMP style dynamic colorizing
Posted: Thu Oct 05, 2017 7:05 pm
Hello all,
I'm trying to colorize images dynamically, during run-time.
For example, I have some mostly gray images that I want to color blue (like what's shown inside the black rectangle).
I'd love to do this with setColor and setBlendMode or similar. But I think I may have to use shaders. So I wrote one to try and achieve the desired effect.
It first converts the set color and the texel to HSV space. The output color will have same hue of set color. I've set the saturation to be the luminance of the image, but I'm not sure what to do about the value part. Copying directly from the image texel seems to result a colorized image that is too dark. So I've multiplied and clamped the value but it's still not quite right..
Anyone have any ideas? See shader code attached (I'm specifically referring to shaders.colorify2).
I'm trying to colorize images dynamically, during run-time.
For example, I have some mostly gray images that I want to color blue (like what's shown inside the black rectangle).
I'd love to do this with setColor and setBlendMode or similar. But I think I may have to use shaders. So I wrote one to try and achieve the desired effect.
It first converts the set color and the texel to HSV space. The output color will have same hue of set color. I've set the saturation to be the luminance of the image, but I'm not sure what to do about the value part. Copying directly from the image texel seems to result a colorized image that is too dark. So I've multiplied and clamped the value but it's still not quite right..
Anyone have any ideas? See shader code attached (I'm specifically referring to shaders.colorify2).