You are on page 1of 1

/* --- Vibrance settings --- */ #define Vibrance 0.

18 //Intelligently saturates (or desaturates if you use nega tive values) the pixels depending on their original saturation. /* --- Defining Constants --- */ sampler s0 : register(s0); /* --- Vibrance --- */ /* by Christian Cann Schuldt Jensen ~ CeeJay.dk Vibrance intelligently boosts the saturation of pixels so pixels that had little color get a larger boost than pixels that had a lot. This avoids oversaturation of pixels that were already very saturated. */ float4 VibrancePass( float4 colorInput ) { float4 color = colorInput; //original input color float3 lumCoeff = float3(0.2126, 0.7152, 0.0722); //Values to calculate luma with float luma = dot(lumCoeff, color.rgb); //calculate luma (grey) float max_color = max(max(colorInput.r,colorInput.g),colorInput.b); //Fi nd the strongest color float min_color = min(min(colorInput.r,colorInput.g),colorInput.b); //Fi nd the weakest color float color_saturation = max_color - min_color; //The difference between the t wo is the saturation //color = lerp(luma, color, (1.0 + (Vibrance * (1.0 - color_saturation)))); // extrapolate between luma and original by 1 + (1-saturation) color = lerp(luma, color, (1.0 + (Vibrance * (1.0 - (sign(Vibrance) * color_sa turation))))); //extrapolate between luma and original by 1 + (1-saturation) return color; //return the result //return color_saturation.xxxx; //Visualize the saturation } /* --- Main --- */ float4 main(float2 tex : TEXCOORD0) : COLOR { float4 c0 = tex2D(s0, tex); c0 = VibrancePass(c0); return c0; }

You might also like