I am currently working on some simple pixel shader in HLSL. I send to shader texture and I want to make it more colorful (something like in the picture below). In the picture 1 there is original texture. Picture 2 shows an effect that I want to achieve. Is there some mathematical formula to do that? My input is the RGBA value of each pixel.EDIT:I'll try to write more concrete. Let's say I want to make that garden texture more red. I suppose that what I need to do is:OutputR = InputR * X,OuputG = InputG * Y,OutputB = InpputB * ZBut how do I find X, Y and Z?
Changing image so it would look like through colorful glasses
texture;algorithm;image processing;hlsl;pixel shader
Extending Kostas Anagnostou's answer, a commonly used formula for desaturation isfloat value = 0.3 * InputR + 0.59 * InputG + 0.11 * InputB;This accomodates the fact that different color hues are perceived with a different intensity by a human observer.Further following the example, you would then define some tint color that is multiplied with the desaturated value. Also you could mix the tinted image with your original to get a less drastic effect. In this case, we're mixing 80% of the desaturated image tinted with (1.0, 0.2, 0.2) with 20% of the original:float3 tint = float3(1.0, 0.2, 0.2);float tintMix = 0.8;OutputR = tintMix * value * tint.r + (1.0 - tintMix) * InputR;OutputG = tintMix * value * tint.g + (1.0 - tintMix) * InputG;OutputB = tintMix * value * tint.b + (1.0 - tintMix) * InputB;