#ifndef _TONEMAP_FXH_
#define _TONEMAP_FXH_
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//  ToneMap Effect by Christian Cann Schuldt Jensen ~ CeeJay.dk
//
//      Implimented by kingeric1992             Nov.4.2017
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//kingeric1992: This is not HDR->LDR ToneMapping Process

struct ToneMapStruct {
    bool   State;
    float  Weight;
    float  Exposure;
    float  Gamma;
    float  Sat;     //[-1, 1]
    float  Bleach;  //[ 0, 1]
    float  Defog;   //[ 0, 1]
    float3 FogColor;
};

//use define so that no need to deal with type?


//FogColor 2 removed
float3 ToneMap( float3 col, ToneMapStruct IN)
{
    if(!IN.State) return col;
    
    col += 0.001;
    
	col = saturate(col - IN.Defog  * IN.FogColor); // Defog
	col*= pow(2.0f, IN.Exposure - 1.0);            // Exposure
	col = pow(col, IN.Gamma);  
//	col = lerp(col, col*float3(1.05, 0.97, 1.27), BlueShift);

	float  l  = dot(col, LUM_COEFF);
    float3 A2 = IN.Bleach * col;
    col += ((1.0 - A2) * A2) * Blend_Overlay(col, l);

	float3 d = col - dot(col, 0.3333);
	return (col + d * IN.Sat)/(1.0+ d*IN.Sat); //saturation
}

#endif //_TONEMAP_FXH_