#ifndef _VIBRANCE_FXH_
#define _VIBRANCE_FXH_
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  Vibrance by Christian Cann Schuldt Jensen ~ CeeJay.dk
//
//      Implimented by kingeric1992             Nov.4.2017
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

struct VibranceStruct {
    bool   State;
    float  Weight;
    float  Curve;
    float3 Strength;
};

float3 Vibrance( float3 col, VibranceStruct IN )
{
    if(!IN.State) return col;
	float sat = max(col.r, max(col.g,col.b)) - min(col.r, min(col.g,col.b));
    
    return lerp(dot(LUM_COEFF, col).rrr, col, max(0.0, 1.0 + IN.Strength * (1.0 - pow(sat, IN.Curve))));
    
//  alt: increase strength when de-vibrance
//  return lerp(dot(LUM_COEFF, col).rrr, col, max(0.0, 1.0 + Strength * (1.0 - sign(Strength)*sat)));
}

#endif //_VIBRANCE_FXH_