//++++++++++++++++++++++++++++++++++++++++++++
// ENBSeries effect file
// visit http://enbdev.com for updates
// Copyright (c) 2007-2013 Boris Vorontsov
//++++++++++++++++++++++++++++++++++++++++++++

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Additions and tweaking by HD6 (HeliosDoubleSix) and LSiwora (2.0.1)
// Prod80: For the disabling interior eye adaptation logic
// Skysan4298: v0.308.4
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// !!! ADV_TWEAK_INGAME IS FOR ADVANCED TWEAK USERS ONLY: USE THIS AT YOUR OWN RISK !!!!
//Only the "Z" value for night and the "W" value for day from ENB GUI Shader window should be used
//When you click the ENB GUI Save button, this file is not updated but the enbseries/enbeffect.fx.ini file would be updated
//I would recommend you update this enbeffect.fx file manually to match that ini file.

//All advanced tweak controls will be enabled when the following "#define ADV_TWEAK_INGAME" line does not have '//' infront
//#define ADV_TWEAK_INGAME

// ENB - values could be 1, 2, 3 or 4. v4 gives unrealistic, kind of artwork style, v5 is added by HD6
	#define POSTPROCESS	5

// To show this mod version number on Shader parameter window
string SkysanVersion="Organic ENB: v0.308.4(c.HQ)";

// ENB - use original game processing first, then mine
	#define APPLYGAMECOLORCORRECTION

	bool DisableBloomMap <
			string UIName =  "Disable Bloom in Map View";
	> = {true};

	bool USE_TOOBRIGHT <
		string UIName =  "Use toobright logic";
	> = {true};

/**
 *	Please use ENB GUI to set Letterbox Option
 */
//Matso's Letterbox effect (set Your FOV to 80.0  or  85.0  or  90.0 in game for better effect)
// blackens top and bottom of the screen
	bool  USE_LETTERBOX_EFFECT <
		string UIName =  "Enable Letterbox";
	> = {false};

	// size of screen to be blacken (in %) - Bars Size	
	float	fLetterboxOffset
	<
		string UIName="  LB: Letter box size, in %";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=25.0;
		float UIStep=0.1;
	> = {7.8};

// HD6 - Enable Vignette - darkens and blurs edges of the screen which increasesfocus on center, film/camera type effect/look
	// didnt bother adding blur, could do without muddying and fuzzing things really
	// and the effect is only meant to be super subtle not a pin hole camera -_-
	//
	bool HD6_VIGNETTE <
		string UIName =  "Enable Vignette";
	> = {false};
	//
	// Defaults below, I darken the corners and the bottom only, leaving the top light
	// darkening all sides feels ike you are trapping/closing in the view too much, so it is not a normal vignette
	// And it is subtle, till you turn it off I doubt you would ever even notice it
	// Also is turned off at night
	//
	float rovigpwr = 0.4; // For Round vignette // 0.2
	float2 sqvigpwr = float2( 0, 0.1 ); // For square vignette: (top, bottom)
	//
	float vsatstrength = 0.25; // How saturated vignette is
	float vignettepow = 1.0; // For Round vignette, higher pushes it to the corners and increases contrast/sharpness
	//
	float vstrengthatnight = 0.2; // How strong vignette is as night, 0-1

// HD6 - Color Balance and Brightness, Contrast adjustment
	//
	#define HD6_COLOR_TWEAKS

// HD6 - Desaturate Nights, can alter saturation seperately from day and night, will affect caves and indoors also for now
	//
	#define HD6_COLORSAT_DAYNIGHT

// HD6 - removes blue tint from bloom, most apparent in distant fog
	//
	#define HD6_BLOOM_DEBLUEIFY

	string blankBRNITE=" ";
	string BRNITE="Brighter Night and Interior";
	bool HD6_BRIGHTER_NIGHTS <
		string UIName =  "Enable Brighter night and interior";
	> = {false};
	float brighterby1 <
		string UIName =  "  BRNITE:Brightness night";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.0};
	float brighterby2 <
		string UIName =  "  BRNITE:Brightness interior";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.05};
// HD6 - see the detail explanation on the dotsize usage below
	// Change size of that dot here, can be 0 to hide it
	float dotsize = 0.003;

//POSTPROCESS 5 by HD6
#if (POSTPROCESS==5)
	// HD6 - Adaptation is now ignored by my choice
	float	EAdaptationMinV2 = 0.10; 
	float	EAdaptationMaxV2 = 0.20;

	// Set ridiculously high, was 8, was in attempt to keep hair colour intact
	string blankETONE=" ";
	string ETONE="ETone Mapping";
	float	EToneMappingCurveV2
	<
		string UIName="EToneMappingCurveV2";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=256.0;
		float UIStep=0.1;
	> = {11.7};

	// Adjusting this will throw out all the other values, icreased to high levels to combat how high I increased ToneMappingCurve to bring some contrast back in to daytime
	float	EIntensityContrastV2
	<
		string UIName="EIntensityContrastV2";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {2.85};

	// high saturation also helps pop the pink/orange sunsets/mornings at 6.30pm and 7.30am, but also nights then get very blue
	// Increasing this will darken things in the process
	// v11.2 = 3.0, 1.0 increased to put even more color into the game
	float	EColorSaturationV2
	<
		string UIName="EColorSaturationV2";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.1;
	> = {3.3};

	// Compensate for darkening caused by increasing EColorSaturationV2	
	float	HCompensateSat
	<
		string UIName="HCompensateSat";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.1;
	> = {2.6};

	// EToneMappingOversaturationV2
	// Wikipedia: "...to map one color to another in order to approximate the appearance of HDR images
	//             in a medium that has a more limited dynamic range..."
	// USE_TONE_OVERSAT is set to false for original Wilds darker look
	bool USE_TONE_OVERSAT <
		string UIName =  "Use ToneMapOversaturation";
	> = {true};

	// Set lower value to get darker like the original Wilds
	float	EToneMappingOversaturationV2
	<
		string UIName="  EToneMappingOversaturationV2";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=512.0;
		float UIStep=0.1;
	> = {200.0};
#endif

#ifdef ADV_TWEAK_INGAME
	bool USE_ADAPT_OVERSAT <
		string UIName =  "  Adds Adaptation on ToneMapOversaturation";
	> = {true};
	float	fEtmovsatMult
	<
		string UIName="  ToneMap Adaptation Muliplier";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=100.0;
		float UIStep=0.1;
	> = {7.0};
	float	fAdaptMinLevel
	<
		string UIName="  Adaptation Minimum Level reset to 1.0";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.3};

	//
	// This is by default and for examples sake set to make the nights even darker
	// When you decrease brightness you will need to increase contrast or it will look washed out
	// and if you increrase contrast that naturally increases saturation so you need to reduce saturation
	// this is just the nature of color correction :-)
	//
	// Note nights and days are being desaturated per channel(RGB) using: HD6_COLORSAT_DAYNIGHT elsewhere
	// Note Bloom is not affected by this and gets its own color/contrast adjustment in HD6_BLOOM_CRISP and HD6_BLOOM_DEBLUEIFY if used
	//
	// If the 3 numbers in rgb below do not add up to 3 it will either be darker or lighter than before
	string blankRGB=" ";
	float3 rgbd <
		string UIName =  "DAY:Color RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.09, 1.01, 1.04};
	float3 rgbn <
		string UIName =  "NIGHT:Color RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.02, 0.96, 1.06};
	float3 rgbi <
		string UIName =  "Interior:Color RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.00, 0.96, 1.04};

	float4 uctbrt1 <
		string UIName =  "Brightness before contrast ";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.30, 0.30, 0.60, 0.80};
	float4 uctbrt2 <
		string UIName =  "Brightness after contrast ";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.30, 0.30, 0.70, 0.92};
	float4 uctcon <
		string UIName =  "Contrast ";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.90, 0.90, 0.93, 0.70};
	float4 uctsat <
		string UIName =  "Saturation ";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.20, -0.80, 1.18, 1.15};

	// HD6 - Eye Adaptation for extreme extreme over bright areas only, such as stupid stupid snow
	float	toobright1 <
		string UIName="toobright: value 1";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.23};
	float	toobright2 <
		string UIName="toobright: value 2";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.5};
	float2	toobright3 <
		string UIName="toobright: Wild Exterior value";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=2.0;
		float UIStep=0.01;
	> = {0.25,0.65};  // Wild value: First value (X) for toobright1, 2nd value (Y) for toobright2

	// HD6 - Desaturate Nights, can alter saturation seperately from day and night, will affect caves and indoors also for now
	float3 dnsatd <
		string UIName =  "DAY:Desaturate RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.03, 1.03, 1.01};
	float3 dnsatn <
		string UIName =  "NIGHT:Desaturate RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {0.95, 0.95, 1.05};
	float3 dnsati <
		string UIName =  "Interior:Desaturate RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.01, 1.01, 1.0};
#else
	bool USE_ADAPT_OVERSAT = true;
	float	fEtmovsatMult = 7.0;
	float	fAdaptMinLevel = 0.3; //ETone Mapping: Adaptation Minimum Level reset to 1.0

	//
	// This is by default and for examples sake set to make the nights even darker
	// When you decrease brightness you will need to increase contrast or it will look washed out
	// and if you increrase contrast that naturally increases saturation so you need to reduce saturation
	// this is just the nature of color correction :-)
	//
	// Note nights and days are being desaturated per channel(RGB) using: HD6_COLORSAT_DAYNIGHT elsewhere
	// Note Bloom is not affected by this and gets its own color/contrast adjustment in HD6_BLOOM_CRISP and HD6_BLOOM_DEBLUEIFY if used
	//
	// If the 3 numbers in rgb below do not add up to 3 it will either be darker or lighter than before
	float3 rgbd 	= float3( 1.09, 1.01, 1.04 ); 		// RGB balance day
	float3 rgbn 	= float3( 1.02, 0.96, 1.06 ); 		// RGB balance night
	float3 rgbi 	= float3( 1.00, 0.96, 1.04 ); 		// RGB balance interior
// HD6 explaination on dotsize
	// First column of the 3 here is for key control only during night
	// ie you can press number '1' with pageup or pagedown to alter the brightness while playing
	// As you press pagedown it moves further towards the values in this first column.
	// As a helpful indicator you can see if you have moved away from default values by
	// noticing a very small white dot in top left corner of screen.
	// Adjust with keys till this dot vanishes, then it is back to default

	float	toobright1 = 0.23;
	float	toobright2 = 0.5;
	float2	toobright3 = float2(0.25, 0.65);   // Wild value: First value (X) for toobright1, 2nd value (Y) for toobright2
	
	#ifndef APPLYGAMECOLORCORRECTION
		//MIDHRAS_KYO: These settings are used if APPLYGAMECOLORCORRECTION is //commented out
		//	keypress 1,2:	  night, day		night, day
		float4 uctbrt1 	= float4( 0.30, 0.30, 		0.40, 0.75 ); 	// Brightness Night, Day (Alters before contrast adjustment)
		float4 uctbrt2	= float4( 0.50, 0.30, 		0.95, 0.90 ); 	// Brightness Night, Day (Alters after contrast adjustment)
		float4 uctcon 	= float4( 0.90, 0.90, 		1.05, 0.75 ); 	// Contrast Night, Day, v11.2: 1.0, 0.97, 0.85
		float4 uctsat	= float4( 0.20, -0.80, 		1.05, 1.10 ); 	// Saturation Night, Day (Remember if using HD6_COLORSAT_DAYNIGHT that will also be desaturating the night)
	#else
		//MIDHRAS_KYO: These settings are used if APPLYGAMECOLORCORRECTION is not commented out
		float4 uctbrt1 	= float4( 0.30, 0.30, 		0.60, 0.80) ; 	// Brightness Night, Day (Alters before contrast adjustment)
		float4 uctbrt2	= float4( 0.30, 0.30, 		0.70, 0.92 ); 	// Brightness Night, Day (Alters after contrast adjustment)
		float4 uctcon 	= float4( 0.90, 0.90, 		0.93, 0.70 ); 	// Contrast Night, Day
		float4 uctsat	= float4( 0.20, -0.80, 		1.18, 1.15 ); 	// Saturation Night, Day (Remember if using HD6_COLORSAT_DAYNIGHT that will also be desaturating the night)
	#endif

	// HD6 - Desaturate Nights, can alter saturation seperately from day and night, will affect caves and indoors also for now
	//
	// Saturation: 		Red, Green, Blue
	float3 dnsatd = float3( 1.03, 1.03, 1.01 );	// Daytime Saturation, Red, Green, Blue
	float3 dnsatn = float3( 0.95, 0.95, 1.05 );	// Nighttime Saturation, Red, Green, Blue
	float3 dnsati = float3( 1.01, 1.01, 1.0 );	// Interior Saturation, Red, Green, Blue
#endif

// Keyboard controlled temporary variables (in some versions exists in the config file).
// Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
	float4	tempF1; // 0,1,2,3
	float4	tempF2; // 5,6,7,8
	float4	tempF3; // 9,0

// x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
	float4	Timer;
// x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
	float4	ScreenSize;
// changes in range 0..1, 0 means that night time, 1 - day time
	float	ENightDayFactor;
	
//changes 0 or 1. 0 means that exterior, 1 - interior
	float	EInteriorFactor;
//changes in range 0..1, 0 means full quality, 1 lowest dynamic quality (0.33, 0.66 are limits for quality levels)
	float	EAdaptiveQualityFactor;

//.x - current weather index, .y - outgoing weather index, .z - weather transition, .w - time of the day in 24 standart hours. 
//Weather index is value from _weatherlist.ini, for example WEATHER002 means index==2, but index==0 means that weather not captured.
float4	WeatherAndTime;

// enb version of bloom applied, ignored if original post processing used
	float	EBloomAmount;

//fov in degrees
float	FieldOfView;

//+++++++++++++++++++++++++++++
//POSTPROCESS 1
	float	EAdaptationMinV1 = 0.05;
	float	EAdaptationMaxV1 = 0.125;
	float	EContrastV1 = 1.0;
	float	EColorSaturationV1 = 1.0;
	float	EToneMappingCurveV1 = 3.0;
//+++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++
//POSTPROCESS 2
#if (POSTPROCESS==2)
	float	EAdaptationMinV2=0.05;
	float	EAdaptationMaxV2=0.125;
	float	EToneMappingCurveV2=8.0;
	float	EIntensityContrastV2=1.475;
	float	EColorSaturationV2=1.0;
	float	EToneMappingOversaturationV2=160.0;
#endif
//+++++++++++++++++++++++++++++


//+++++++++++++++++++++++++++++
//POSTPROCESS 3
	float	EAdaptationMinV3 = 0.005; // Higher Gets Darker
	float	EAdaptationMaxV3 = 0.125;
	float	EToneMappingCurveV3 = 4.0; // Higher gets darker
	float	EToneMappingOversaturationV3 = 60.0;
//+++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++
//POSTPROCESS 4
	float	EAdaptationMinV4 = 0.2;
	float	EAdaptationMaxV4 = 0.125;
	float	EBrightnessCurveV4 = 0.7;
	float	EBrightnessMultiplierV4 = 0.45;
	float	EBrightnessToneMappingCurveV4 = 0.3;
//+++++++++++++++++++++++++++++

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// PALETTE MIXER - controls the intensity of the enbpalette.bmp file IN THE FINAL MIX
/**
 *	SET strength of Palette texture in overall color mix
 *	WORKS INDEPENDANTLY for PP2, 5, 6 and 7
 *	WORKS INDEPENDANTLY with APPLYGAMECOLORCORRECTION TOGGLE
 */
//parameters for enbseries.ini's UsePaletteTexture=true
	string blankPM=" ";
	string palette="Palatte Mixer";
	bool USE_PALETTE_MIXER <
		string UIName =  "Enable Palette Mixer";
	> = {true};
	bool HD6_PALETTE_MIXER <
		string UIName="  Use New Palette Mixer";
	> = {true};
	float palmixDay <
		string UIName="  Palette Day intensity";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.8};
	float palmixNight <
		string UIName="  Palette Night intensity";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.5};
	float palmixInterior <
		string UIName="  Palette Interior intensity";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
		float UIStep=0.01;
	> = {0.45};

	string blankBLOOM=" ";
	string bloom="Bloom";
	bool EnabledBloom <
			string UIName =  "Enabled ENB Bloom";
	> = {true}; // HD6 - Enable Bloom - disable bloom with this if you turn it off in enbseries, compensates for darkening
	bool HD6_NO_BLOOMGLARE <
		string UIName =  "Disable Bloom Glare";
	> = {true};
	float BLOOMGLARE_INTENSITY <
		string UIName="  Bloom Glare Intensity";
		string UIWidget="Spinner";
		float UIMin=0.01;
		float UIMax=1.0;
		float UIStep=0.01;
	> = { 0.10 };

	bool USE_WILDS_V3_BLOOM <
		string UIName =  "Wilds v3 Bloom";
	> = {false};
	float WILDS_Brite_DayExt <
		string UIName =  "  Wilds:Brightness Exterior Day";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.0};	
	float WILDS_Brite_NiteExt <
		string UIName =  "  Wilds:Brightness Exterior Night";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {-0.08};	
	float WILDS_Contrast_DayExt <
		string UIName =  "  Wilds:Contrast Exterior Day";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.15};	
	float WILDS_Contrast_NiteExt <
		string UIName =  "  Wilds:Contrast Exterior Night";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.12};	

	bool WILDS_V3_BLOOM_INT <
		string UIName =  "Wilds v3 Bloom Interior only";
	> = {true};
	float WILDS_Brite_Int <
		string UIName =  "  Wilds:Brightness Interior";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.0};	
	float WILDS_Contrast_Int <
		string UIName =  "  Wilds:Contrast Interior";
		string UIWidget="Spinner";
		float UIMin=-10.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.02};	
	float HD6_INT_BLOOM_ADDITION <
		string UIName="HD6 Interior Bloom addition";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=0.1;
		float UIStep=0.01;
	> = {0.07};

	bool USE_NEW_DEBLUEIFY <
		string UIName =  "Use New BloomDeblueify";
	> = {true};

// HD6 - BLOOM - alternate crisp bloom, no hazey mud (hopefully)
	bool HD6_BLOOM_CRISP <
		string UIName =  "Enable Bloom Crisp";
	> = {true};

#ifdef ADV_TWEAK_INGAME
	// Deblueify balance:	Red, Green, Blue
	float3 bsatd <
		string UIName =  "  DAY:Deblueify RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.00, 1.00, 1.00};
	float3 bsatn <
		string UIName =  "  NIGHT:Deblueify RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.30, 1.30, 1.30};
	float3 bsati <
		string UIName =  "  Interior:Deblueify RGB ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {1.10, 1.10, 1.10};

// Wilds Bloom settings
	float CBrightnessDay <
		string UIName=" DAY:Brightness";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float CContrastDay <
		string UIName=" DAY:Contrast";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float CSaturationDay <
		string UIName=" DAY:Saturation";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float BrightnessModDay <
		string UIName=" DAY:Brightness compensate";	// Compensate the brightness when no bloom is used
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.23};
	float BrightnessMultDay <
		string UIName=" DAY:Brightness compensate multiplier";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.4};
	float CompSBDay <
		string UIName=" DAY:Bloom limiter";		// Limits where the bloom will "bloom"
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomStrDay <
		string UIName=" DAY:Bloom Strength";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomBlendDay <
		string UIName=" DAY:Bloom Blend";		// How much blend there will be between ENB and Vanilla bloom
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.65};
	float BlendCompDay <
		string UIName=" DAY:Bloom Blend compensate";	// Compensate for brightening caused by above bloom blend
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float3 LumCoeffDay <
		string UIName =  " DAY:Brightness LumCoeff ";	// Increases brightness around "bloomy" spots
		string UIWidget="Vector";
		float UIStep=0.0001;
	> = {0.2125, 0.7154, 0.0721};
	float3 AvgLuminDay <
		string UIName =  " DAY:Contrast AvgLumin ";	// Increases contrast around "bloomy" spots
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {0.5, 0.5, 0.5};
	float TrigDay <
		string UIName=" DAY:Trigger limit";		// Limits what triggers a bloom
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.0};
	float SBrightDay <
		string UIName=" DAY:Superbright spots";		// Limits bloom to superbright spots only
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float CBrightnessNight <
		string UIName=" NIGHT:Brightness";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float CContrastNight <
		string UIName=" NIGHT:Contrast";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.1};
	float CSaturationNight <
		string UIName=" NIGHT:Saturation";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.8};
	float BrightnessModNight <
		string UIName=" NIGHT:Brightness compensate";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.12};
	float BrightnessMultNight <
		string UIName=" NIGHT:Brightness compensate multiplier";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.1};
	float CompSBNight <
		string UIName=" NIGHT:Bloom limiter";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomStrNight <
		string UIName=" NIGHT:Bloom Strength";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomBlendNight <
		string UIName=" NIGHT:Bloom Blend";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float BlendCompNight <
		string UIName=" NIGHT:Bloom Blend compensate";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.8};
	float3 LumCoeffNight <
		string UIName =  " NIGHT:Brightness LumCoeff ";
		string UIWidget="Vector";
		float UIStep=0.0001;
	> = {0.2125, 0.7154, 0.0721};
	float3 AvgLuminNight <
		string UIName =  " NIGHT:Contrast AvgLumin ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {0.5, 0.5, 0.5};
	float TrigNight <
		string UIName=" NIGHT:Trigger limit";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.18};
	float SBrightNight <
		string UIName=" NIGHT:Superbright spots";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float CBrightnessInterior <
		string UIName=" Interior:Brightness";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float CContrastInterior <
		string UIName=" Interior:Contrast";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.1};
	float CSaturationInterior <
		string UIName=" Interior:Saturation";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.8};
	float BrightnessModInterior <
		string UIName=" Interior:Brightness compensate";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.12};
	float BrightnessMultInterior <
		string UIName=" Interior:Brightness compensate multiplier";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.12};
	float CompSBInterior <
		string UIName=" Interior:Bloom limiter";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomStrInterior <
		string UIName=" Interior:Bloom Strength";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {1.0};
	float BloomBlendInterior <
		string UIName=" Interior:Bloom Blend";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};
	float BlendCompInterior <
		string UIName=" Interior:Bloom Blend compensate";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.78};
	float3 LumCoeffInterior <
		string UIName =  " Interior:Brightness LumCoeff ";
		string UIWidget="Vector";
		float UIStep=0.0001;
	> = {0.2125, 0.7154, 0.0721};
	float3 AvgLuminInterior <
		string UIName =  " Interior:Contrast AvgLumin ";
		string UIWidget="Vector";
		float UIStep=0.01;
	> = {0.5, 0.5, 0.5};
	float TrigInterior <
		string UIName=" Interior:Trigger limit";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.18};
	float SBrightInterior <
		string UIName=" Interior:Superbright spots";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
		float UIStep=0.01;
	> = {0.7};

//parameters for ldr color correction, if enabled in enbseries.ini's UseProceduralCorrection=true
	string blankCC=" ";
	string ldrCC="LDR Color Correction";
	float	ECCGammaExt
	<
		string UIName="CC: Gamma Exterior";
		string UIWidget="Spinner";
		float UIMin=0.2;//not zero!!!
		float UIMax=5.0;
	> = {1.0};
	float	ECCGammaInt
	<
		string UIName="CC: Gamma Interior";
		string UIWidget="Spinner";
		float UIMin=0.2;//not zero!!!
		float UIMax=5.0;
	> = {1.02};
	float	ECCInBlack
	<
		string UIName="CC: In black";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
	> = {0.0};
	float	ECCInWhite
	<
		string UIName="CC: In white";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
	> = {1.0};
	float	ECCOutBlack
	<
		string UIName="CC: Out black";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
	> = {0.0};
	float	ECCOutWhite
	<
		string UIName="CC: Out white";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
	> = {1.0};
	float	ECCBrightness
	<
		string UIName="CC: Brightness";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
	> = {1.0};
	float	ECCContrastGrayLevel
	<
		string UIName="CC: Contrast gray level";
		string UIWidget="Spinner";
		float UIMin=0.01;
		float UIMax=0.99;
	> = {0.5};
	float	ECCContrast
	<
		string UIName="CC: Contrast";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
	> = {1.0};
	float	ECCSaturation
	<
		string UIName="CC: Saturation";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=10.0;
	> = {1.0};
	float	ECCDesaturateShadows
	<
		string UIName="CC: Desaturate shadows";
		string UIWidget="Spinner";
		float UIMin=0.0;
		float UIMax=1.0;
	> = {0.0};
	float3	ECCColorBalanceShadows <
		string UIName="CC: Color balance shadows";
		string UIWidget="Color";
	> = {0.5, 0.5, 0.5};
	
	float3	ECCColorBalanceHighlights <
		string UIName="CC: Color balance highlights";
		string UIWidget="Color";
	> = {0.5, 0.5, 0.5};
	float3	ECCChannelMixerR <
		string UIName="CC: Channel mixer R";
		string UIWidget="Color";
	> = {1.0, 0.0, 0.0};
	float3	ECCChannelMixerG <
		string UIName="CC: Channel mixer G";
		string UIWidget="Color";
	> = {0.0, 1.0, 0.0};
	float3	ECCChannelMixerB <
		string UIName="CC: Channel mixer B";
		string UIWidget="Color";
	> = {0.0, 0.0, 1.0};
#else
	// Deblueify balance:	Red, Green, Blue
	float3 bsatd = float3( 1.00, 1.00, 1.00 );	// Daytime Deblueify, Red, Green, Blue
	float3 bsatn = float3( 1.30, 1.30, 1.30 );	// Nighttime Deblueify, Red, Green, Blue
	float3 bsati = float3( 1.10, 1.10, 1.10 );	// Interior Deblueify, Red, Green, Blue

// Wilds Bloom settings
	float CBrightnessDay = 1.0;
	float CContrastDay = 1.0;
	float CSaturationDay = 0.7;
	float BrightnessModDay = 0.23;
	float BrightnessMultDay = 1.4;
	float CompSBDay = 1.0;
	float BloomStrDay = 1.0;
	float BloomBlendDay = 0.65;
	float BlendCompDay = 0.7;
	float3 LumCoeffDay = float3(0.2125, 0.7154, 0.0721);
	float3 AvgLuminDay = float3(0.5, 0.5, 0.5);
	float TrigDay = 0.0;
	float SBrightDay = 0.7;
	float CBrightnessNight = 1.0;
	float CContrastNight = 1.1;
	float CSaturationNight = 0.8;
	float BrightnessModNight = 0.12;
	float BrightnessMultNight = 1.1;
	float CompSBNight = 1.0;
	float BloomStrNight = 1.0;
	float BloomBlendNight = 0.7;
	float BlendCompNight = 0.8;
	float3 LumCoeffNight = float3(0.2125, 0.7154, 0.0721);
	float3 AvgLuminNight = float3(0.5, 0.5, 0.5);
	float TrigNight = 0.18;
	float SBrightNight = 0.7;
	float CBrightnessInterior = 1.0;
	float CContrastInterior = 1.1;
	float CSaturationInterior = 0.8;
	float BrightnessModInterior = 0.12;
	float BrightnessMultInterior = 1.12;
	float CompSBInterior = 1.0;
	float BloomStrInterior = 1.0;
	float BloomBlendInterior = 0.7;
	float BlendCompInterior = 0.78;
	float3 LumCoeffInterior = float3(0.2125, 0.7154, 0.0721);
	float3 AvgLuminInterior = float3(0.5, 0.5, 0.5);
	float TrigInterior = 0.18;
	float SBrightInterior = 0.7;

//parameters for ldr color correction, if enabled in enbseries.ini's UseProceduralCorrection=true
	float	ECCGammaExt = 1.0;
	float	ECCGammaInt = 1.02;
	float	ECCInBlack = 0.0;
	float	ECCInWhite = 1.0;
	float	ECCOutBlack = 0.0;
	float	ECCOutWhite = 1.0;
	float	ECCBrightness = 1.0;
	float	ECCContrastGrayLevel = 0.5;
	float	ECCContrast = 1.0;
	float	ECCSaturation = 1.0;
	float	ECCDesaturateShadows = 0.0;
	float3	ECCColorBalanceShadows = float3(0.5, 0.5, 0.5);
	float3	ECCColorBalanceHighlights = float3(0.5, 0.5, 0.5);
	float3	ECCChannelMixerR = float3(1.0, 0.0, 0.0);
	float3	ECCChannelMixerG = float3(0.0, 1.0, 0.0);
	float3	ECCChannelMixerB = float3(0.0, 0.0, 1.0);
#endif

//+++++++++++++++++++++++++++++
//external parameters, do not modify
//+++++++++++++++++++++++++++++
	texture2D texs0; // color
	texture2D texs1; // bloom skyrim
	texture2D texs2; // adaptation skyrim
	texture2D texs3; // bloom enb
	texture2D texs4; // adaptation enb
	texture2D texs7; // palette enb

sampler2D _s0 = sampler_state {
	Texture   = <texs0>;
	MinFilter = POINT;
	MagFilter = POINT;
	MipFilter = NONE; // LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D _s1 = sampler_state {
	Texture   = <texs1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE; // LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D _s2 = sampler_state {
	Texture   = <texs2>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE; // LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D _s3 = sampler_state {
	Texture   = <texs3>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE; // LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D _s4 = sampler_state {
	Texture   = <texs4>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE; // LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D _s7 = sampler_state {
	Texture   = <texs7>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

struct VS_OUTPUT_POST {
	float4 vpos  	: POSITION;
	float2 txcoord0 : TEXCOORD0;
};

struct VS_INPUT_POST {
	float3 pos 		: POSITION;
	float2 txcoord0 : TEXCOORD0;
};

VS_OUTPUT_POST VS_Quad(VS_INPUT_POST IN){
	VS_OUTPUT_POST OUT;
	OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
	OUT.txcoord0.xy=IN.txcoord0.xy;
	return OUT;
};

//skyrim shader specific externals, do not modify
	float4 _c1 : register(c1); float4 _c2 : register(c2); float4 _c3 : register(c3);
	float4 _c4 : register(c4); float4 _c5 : register(c5);

float4 PS_D6EC7DD1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR {
	float4 _oC0 = 0.0; // output
	float4 _c6 = float4(0, 0, 0, 0);
	float4 _c7 = float4(0.212500006, 0.715399981, 0.0720999986, 1.0);
	float4 r0; float4 r1; float4 r2; float4 r3; float4 r4; float4 r5; float4 r6;
	float4 r7; float4 r8; float4 r9; float4 r10; float4 r11; float4 _v0=0.0; 
	_v0.xy = IN.txcoord0.xy;
    	r1=tex2D(_s0, _v0.xy); // color
	r11=r1; // my bypass
	_oC0.xyz=r1.xyz; // for future use without game color corrections
	if(DisableBloomMap && WeatherAndTime.x == 99)
	{
		return r11;
	}
	bool useBloom = EnabledBloom;
	bool useWildsBloom = USE_WILDS_V3_BLOOM;
	bool usePaletteMixer = USE_PALETTE_MIXER;
	if(EInteriorFactor && WILDS_V3_BLOOM_INT) {
		useWildsBloom = true;
	}
	if(useWildsBloom) {
		usePaletteMixer = false;
	}
	// HD6 - You can play with the night/day value here, not that its advisable to :-D
	// Visualize this with 'debug triangle' further down
	float hnd = ENightDayFactor;
	float ji = 1 - EInteriorFactor;
	
	float2 hndtweak = float2( 3.1 , 1.5 );
	float vhnd = hnd; // effects vignette stregth;
	float bchnd = hnd; // effects hd6 bloom crisp
	float cdhnd = hnd; // effects hd6 colorsat daynight
	
	// Some caves are seen as daytime, so I set key 3 to force nightime
	// This doesnt work very well >_<
	//hnd = tempF1.z < 1 ? 0 : hnd;
	//hndtweak.x = tempF1.z < 1 ? hndtweak.y : hndtweak.x; // Dont ask, I have no idea why I need this lol
	// Fixed: HD6 didn't have access to the newer ENB EInteriorFactor flag
	hnd = EInteriorFactor ? 0 : hnd;
	
	
	// HD6 - Alter Brightness using keyboard during gameplay
		
		float4 tuctbrt1 = uctbrt1;
		float4 tuctbrt2 = uctbrt2;
		float4 tuctcon  = uctcon;
		float4 tuctsat  = uctsat;
	if (EInteriorFactor)
	{	
		if (HD6_BRIGHTER_NIGHTS)
		{
			tuctbrt1.z += brighterby2;
		}
		
		if(WILDS_V3_BLOOM_INT) {
			tuctbrt2.z += WILDS_Brite_Int;
			tuctcon.z += WILDS_Contrast_Int;
		}
	}			
	else
	{
		if (HD6_BRIGHTER_NIGHTS)
		{
			tuctbrt1.z += brighterby1;
		}
		
		if(USE_WILDS_V3_BLOOM) {
			tuctbrt2.z += WILDS_Brite_NiteExt;
			tuctbrt2.w += WILDS_Brite_DayExt;
			tuctcon.z += WILDS_Contrast_NiteExt;
			tuctcon.w += WILDS_Contrast_DayExt;
		}
	}			
		float h1 = lerp(-1,1,tempF1.x); // Increases speed it changes by when pressing key		
		h1 = lerp( h1, 1, hnd ); // Removes affect during day		
		h1 = h1 - (h1 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
		float hbs = lerp( EBloomAmount/2, EBloomAmount, h1); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
		
		float h2 = lerp(-1,1,tempF1.y); // Increases speed it changes by when pressing key
		h2 = lerp( 1, h2, hnd ); // Removes affect during night
		h2 = h2 - (h2 % 0.1); // Changes it so incriments are in steps, remove this if you want smooth changes when pressing keys
		hbs = lerp( (hbs/2)-1, hbs, h2); // Reduce bloom as it gets darker, otherwise it just gets hazier, higher number reduces bloom more as it gets darker
		hbs = max(0,hbs);
		hbs = min(2,hbs); // should be able to go above 1, but not 2
		
		vhnd = lerp(-2,hnd,h2);
		vhnd = max(0,vhnd); // do not go below 0;
		vhnd = min(1,vhnd); // not above 1, just incase people like surface of sun

		cdhnd=bchnd=vhnd;
		
		#ifdef HD6_COLOR_TWEAKS
			//float2 uctbrt1t = 	float2( lerp( tuctbrt1.x, 	tuctbrt1.y, h1), tuctbrt1.z );
			//float2 uctbrt2t = 	float2( lerp( tuctbrt2.x, 	tuctbrt2.y,	h1), tuctbrt2.y );			
			//float2 uctcont  =	float2( lerp( tuctcon.x, 	tuctcon.y, 	h1), tuctcon.z );
			//float2 uctsatt  =	float2( lerp( tuctsat.x, 	tuctsat.y, 	h1), tuctsat.z );
			float2 uctbrt1t = 	float2( lerp( tuctbrt1.x, 	tuctbrt1.z, h1), lerp( tuctbrt1.y, 	tuctbrt1.w, h2) );
			float2 uctbrt2t = 	float2( lerp( tuctbrt2.x, 	tuctbrt2.z,	h1), lerp( tuctbrt2.y, 	tuctbrt2.w, h2) );			
			float2 uctcont  =	float2( lerp( tuctcon.x, 	tuctcon.z, 	h1), lerp( tuctcon.y, 	tuctcon.w, h2) );
			float2 uctsatt  =	float2( lerp( tuctsat.x, 	tuctsat.z, 	h1), lerp( tuctsat.y, 	tuctsat.w, h2) );
		#endif
		
	////
	
	
	
	#ifdef APPLYGAMECOLORCORRECTION
		//apply original
		r0.x=1.0/_c2.y;
		r1=tex2D(_s2, _v0);

		// HD6 - disable vanilla adapation... because it drives me CRAAAZY!!!!! >_<
		r1.xyz = lerp( min( 0.28, r1.xyz ), 0.5, hnd ); // Ligthen if dark, but do not darken if too light, we do this elsewhere for extreme bright situations
		// No seriously it screws up when looking at bright lights at night and the sky during day
		
		
		
		r0.yz=r1.xy * _c1.y;
		r0.w=1.0/r0.y;
		r0.z=r0.w * r0.z;
		r1=tex2D(_s0, _v0);
		r1.xyz=r1 * _c1.y;
		r0.w=dot(_c7.xyz, r1.xyz);
		r1.w=r0.w * r0.z;
		r0.z=r0.z * r0.w + _c7.w;
		r0.z=1.0/r0.z;
		r0.x=r1.w * r0.x + _c7.w;
		r0.x=r0.x * r1.w;
		r0.x=r0.z * r0.x;
		if (r0.w<0) r0.x=_c6.x;
		r0.z=1.0/r0.w;
		r0.z=r0.z * r0.x;
		r0.x=saturate(-r0.x + _c2.x);
		//r2=tex2D(_s3, _v0);//enb bloom
		r2=tex2D(_s1, _v0);//skyrim bloom

		if (HD6_NO_BLOOMGLARE)
		{
			r2.xyz=0.0; // HD6: Screw it bloom should not happen here at all so just set to 0
		}
		else
		{
			float its = BLOOMGLARE_INTENSITY;
			r2.xyz = r2.xyz * (EInteriorFactor ? its : its * 2);
		}
		r2+= EInteriorFactor ? HD6_INT_BLOOM_ADDITION : 0.1; // HD6 - I add 0.1 to lighten it a bit, probably not great place to do it now

		r2.xyz=r2 * _c1.y;
		r2.xyz=r0.x * r2;
				
		r1.xyz=r1 * r0.z + r2;
		r0.x=dot(r1.xyz, _c7.xyz);
		r1.w=_c7.w;
		
		r2=lerp(r0.x, r1, _c3.x);
			
		r1=r0.x * _c4 - r2;
		r1=_c4.w * r1 + r2;
		r1=_c3.w * r1 - r0.y; // khajiit night vision _c3.w
		r0=_c3.z * r1 + r0.y;
		r1=-r0 + _c5;
		
		_oC0=_c5.w * r1 + r0;
	#endif // APPLYGAMECOLORCORRECTION

	float4 color=_oC0;		
	
	//HD6 brighten when not using original gamma, so they are at least similiar
	// Bloom is diminshed for some reason, oh well, i dont use this
	#ifndef APPLYGAMECOLORCORRECTION
		color*=1.2;
		color+=0.1;			
	#endif
	
	#ifdef HD6_COLORSAT_DAYNIGHT
		// HeliosDoubleSix code to Desaturate at night	
		// What channels to desaturate by how much, so you could just reduce blue at night and nothing else	
		// doesnt seem quite right will tinge things green if you just remove blue :-/ thought perhaps that makes perfect sense :-) *brain hurts*
		// Remember this affects caves, so might be best to remove saturation from nighttime direct and ambient light
		float3 nsatn= lerp( dnsati, ( lerp( dnsatn, dnsatd, hnd ) ), ji );
		float3 oldcoln = color.xyz; // store old values
		color.xyz *= nsatn; // adjust saturation	
		
		// spread lost luminace over everything
		float3 greycn = float3(0.333,0.333,0.333); // screw perception

		color.xyz += (oldcoln.x-(oldcoln.x*nsatn.x)) * greycn.x;
		color.xyz += (oldcoln.y-(oldcoln.y*nsatn.y)) * greycn.y;
		color.xyz += (oldcoln.z-(oldcoln.z*nsatn.z)) * greycn.z;
	#endif	
	
	//adaptation in time
	float4	Adaptation=tex2D(_s4, 0.5);
	float	grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);

	float4	xcolorbloom=tex2D(_s3, _v0.xy); //bloom
	
	#ifdef HD6_BLOOM_DEBLUEIFY
		float3 nsat = float3( 0.7, 0.7, 0.7);  // Wilds v2.0.1 bloom deblueify value
		if (USE_NEW_DEBLUEIFY)
		{
			// Wilds v3 FINAL: --JawZ-- added day, night and interior debluify	// KYO : Bingo !
			nsat= lerp( bsati, ( lerp( bsatn, bsatd, hnd ) ), ji );
		}
		// store old values
			float3 oldcol=xcolorbloom.xyz;
			
		// adjust saturation
			xcolorbloom.xyz *= nsat;
			
		// spread lost luminace over everything
			float3 greyc = float3(0.333,0.333,0.333); // screw perception
			xcolorbloom.xyz += (oldcol.x-(oldcol.x*nsat.x)) * greyc.x;
			xcolorbloom.xyz += (oldcol.y-(oldcol.y*nsat.y)) * greyc.y;
			xcolorbloom.xyz += (oldcol.z-(oldcol.z*nsat.z)) * greyc.z;
	#endif

	// Altering color balance is confusing, also Im not entirely sure it works properly :-D
	#ifdef HD6_COLOR_TWEAKS
		float ctbrt1 = lerp(uctbrt1t.x,uctbrt1t.y,hnd); // Brightness Night, Day (Alters before contrast adjustment)
		float ctbrt2 = lerp(uctbrt2t.x,uctbrt2t.y,hnd); // Brightness Night, Day (Alters after contrast adjustment)
		float ctcon = lerp(uctcont.x,uctcont.y,hnd); // Contrast Night, Day
		float ctsat = lerp(uctsatt.x,uctsatt.y,hnd); // Saturation Night, Day
		
		float3 ctLumCoeff = float3(0.2125, 0.7154, 0.0721);				
		float3 ctAvgLumin = float3(0.5, 0.5, 0.5);
		float3 ctbrtColor = color.rgb * ctbrt1;

		float3 ctintensity = dot(ctbrtColor, ctLumCoeff);
		float3 ctsatColor = lerp(ctintensity, ctbrtColor, ctsat); 
		float3 cconColor = lerp(ctAvgLumin, ctsatColor, ctcon);
		
		color.xyz = cconColor * ctbrt2;
		float3 cbalance = lerp(rgbi, ( lerp (rgbn,rgbd, hnd) ), ji);
		color.xyz=cbalance.xyz * color.xyz;
	#endif
	
	
	if(useBloom) {
		if (HD6_BLOOM_CRISP)
		{
			float3 LumCoeff = lerp( LumCoeffInterior, ( lerp( LumCoeffNight, LumCoeffDay,  bchnd ) ), ji);			
			float3 AvgLumin = lerp( AvgLuminInterior, ( lerp( AvgLuminNight, AvgLuminDay,  bchnd ) ), ji);	
			color*=1.06;
			color*=1.0; // Brighten it up without loosing contrast
				//color += lerp(0.1,0.1,bchnd); // Night, Day, increase kinda lowers contrast, but makes things look more washed out also, this is to lift black areas really
				//color+=((color/2)*EBloomAmount);
				//xcolorbloom-=0.4;
				//xcolorbloom=max(xcolorbloom,0); // will cause color shift/desaturation also
			if (useWildsBloom)
			{
				color.xyz+=(color.xyz*(xcolorbloom*EBloomAmount*0.2))+(xcolorbloom/1.5);
			}
				//color.xyz=(color.xyz*color.xyz)/2;			
				//color.xyz=(color.xyz*0.5)+((color.xyz*(xcolorbloom*EBloomAmount))*0.5);
				//color.xyz*=0.8;		
				//color.xyz*=1.4;
				
			// Limits what triggers a bloom
			float3 brightbloom = xcolorbloom - lerp( TrigInterior, ( lerp( TrigNight, TrigDay,  bchnd ) ), ji);
			brightbloom = max( brightbloom , 0);
			
			// Limits bloom to superbright spots only
			float3 superbright = xcolorbloom - lerp( SBrightInterior, ( lerp( SBrightNight, SBrightDay,  bchnd ) ), ji);
			superbright = max( superbright , 0 ) ; // crop so dont go any lower than black
				//superbright = lerp( AvgLumin, superbright, 0.5); // Contrast
			superbright *= 0.6;
			
			// HD6 - Bloom - Brightntess, Contrast, Saturation adjustment 1,1,1 for no change // Remember this is bloom only being altered
			// Bloom - Brightness, Contrast and Saturation
			float3 brt = lerp( CBrightnessInterior, ( lerp( CBrightnessNight, CBrightnessDay,   bchnd ) ), ji);
			float3 con = lerp( CContrastInterior, ( lerp( CContrastNight, CContrastDay,   bchnd ) ), ji);
			float3 sat = lerp( CSaturationInterior, ( lerp( CSaturationNight, CSaturationDay,   bchnd ) ), ji);
				
				float3 brtColor = brightbloom * brt;
				float3 cintensity = dot( brtColor, LumCoeff );
				float3 satColor = lerp( cintensity, brtColor, sat ); 
				float3 conColor = lerp( AvgLumin, satColor, con );
				conColor -= 0.3;
				brightbloom = conColor;
				
				
				
			// These 2 should compensate so when even when no bloom exists it still matches brightness of scene without ENB
			color.xyz +=  lerp( BrightnessModInterior, ( lerp( BrightnessModNight, BrightnessModDay, bchnd ) ), ji);
			color.xyz *= lerp( BrightnessMultInterior, ( lerp( BrightnessMultNight, BrightnessMultDay, bchnd ) ), ji);
			
			// Now Add bloom and compensate for any brightness changes that introduces
			color.xyz += (( superbright * hbs ) * lerp( CompSBInterior, ( lerp( CompSBNight, CompSBDay,  bchnd ) ), ji)); // Limits where the bloom will "bloom"
			brightbloom -= ( superbright * 2 ); // removes superbright from brightbloom so I dont bloom the brightest area twice
			brightbloom = max( brightbloom , 0.0 );
			color.xyz += (( brightbloom * hbs ) * lerp( BloomStrInterior, ( lerp( BloomStrNight, BloomStrDay,  bchnd ) ), ji)); // How strong the bloom will be

			// This blends the the ENB and Skyrim bloom together, for a more hazey effect
			color.xyz += (xcolorbloom.xyz * hbs) * lerp( BloomBlendInterior, ( lerp( BloomBlendNight, BloomBlendDay,  bchnd ) ), ji); // How much the blend there will be
			color.xyz *= lerp( BlendCompInterior, ( lerp( BlendCompNight, BlendCompDay,  bchnd ) ), ji); // compensate for brightening caused by above bloom
		}
		else
		{
			float tt=1;
			color.xyz+=((xcolorbloom.xyz*EBloomAmount)*tt);
		} 
	} else {
		// No bloom
		color+=((color/1)*EBloomAmount); // compensate if bloom disabled
	}
		
	//+++++++++++++++++++++++++++++
		
	if (HD6_VIGNETTE)
	{
		// HD6: yes this is my own crazy creation after seing how boring the usual linear circle vignettes typically are
		// no doubt I have done it in an overly convoluted way :-)
		float2 inTex = _v0;	
		float4 voriginal = r1;
		float4 vcolor = voriginal;
		vcolor.xyz=1;
		inTex -= 0.5; // Centers vignette
		inTex.y += 0.01; // Move it off center and up so it obscures sky less
		float vignette = 1.0 - dot( inTex, inTex );
		vcolor *= pow( vignette, vignettepow );
		
		
		// Round Vignette
		float4 rvigtex = vcolor;
		rvigtex.xyz = pow( vcolor, 1 );
		rvigtex.xyz = lerp(float3(0.5, 0.5, 0.5), rvigtex.xyz, 2.0); // Increase Contrast
		rvigtex.xyz = lerp(float3(1,1,1),rvigtex.xyz,rovigpwr); // Set strength of round vignette
		
		// Square Vignette (just top and bottom of screen)
		float4 vigtex = vcolor;
		vcolor.xyz = float3(1,1,1);
		float3 topv = min((inTex.y+0.5)*2,0.5) * 2; // Top vignette
		float3 botv = min(((0-inTex.y)+0.5)*2,0.5) * 2; // Bottom vignette
		
		topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
		botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
		vigtex.xyz = (topv)*(botv);
		
		// Add round and square together
		vigtex.xyz*=rvigtex.xyz; 
		
		vigtex.xyz = lerp(vigtex.xyz,float3(1,1,1),(1-vstrengthatnight)*(1-vhnd)); // Alter Strength at night
		
		vigtex.xyz = min(vigtex.xyz,1);
		vigtex.xyz = max(vigtex.xyz,0);
				
		// Increase saturation where edges were darkenned
		float3 vtintensity = dot(color.xyz, float3(0.2125, 0.7154, 0.0721));
		color.xyz = lerp(vtintensity, color.xyz, ((((1-(vigtex.xyz*2))+2)-1)*vsatstrength)+1  );
		
		color.xyz *= (vigtex.xyz);
	}
	
	// HD6 - Warning, Code below appears to reduce 'color.xyz' to 8bit / LDR
		
		
	// HD6 - Eye Adaptation for extreme extreme over bright areas only, such as stupid stupid snow
	// 0.3, 0.9 - affects day time sunny day = bad
	if (USE_TOOBRIGHT)
	{
		float toobright = max(0,tex2D(_s2, _v0).xyz - (USE_WILDS_V3_BLOOM ? toobright3.x : toobright1)); // 0.5
		color.xyz *= 1-((USE_WILDS_V3_BLOOM ? toobright3.y : toobright2) * toobright); // 1.3
	}
	// <Lazy> HD6 - dopey arse code to alter enbpalette because im too lazy to open photoshop
	// when using your own palette remove this.. ill fix this.. next
	float palmix = 0.8; // 0.4
	if (HD6_PALETTE_MIXER)
	{
		// Wilds v3 FINAL: palette mixer for day, night, and interior
		palmix = lerp( palmixInterior, ( lerp( palmixNight, palmixDay, hnd ) ), ji );
	}

	if (usePaletteMixer)
	{	
		color.xyz*=lerp( 1.0, 1.10, palmix); // 0.9
	}
	// </Lazy>

	float s1 = lerp(-1,1,tempF1.w); // Increases speed it changes by when pressing key		
	s1 = s1 - (s1 % 0.1);
	
	float3 sat1 = float3(0,0,0);
	float3 sat2 = float3(1,1,1);
	
	float3 snsat = lerp(sat1,sat2,s1);
	// store old values
		float3 soldcol=color.xyz;
		
	// adjust saturation
		color.xyz *= snsat;
		
	// spread lost luminace over everything
		float3 sgreyc = float3(0.333,0.333,0.333); // screw perception
		color.xyz += (soldcol.x-(soldcol.x*snsat.x)) * sgreyc.x;
		color.xyz += (soldcol.y-(soldcol.y*snsat.y)) * sgreyc.y;
		color.xyz += (soldcol.z-(soldcol.z*snsat.z)) * sgreyc.z;
		
		
	//+++++++++++++++++++++++++++++
	#if (POSTPROCESS==1)
		grayadaptation=max(grayadaptation, 0.0);
		grayadaptation=min(grayadaptation, 50.0);
		color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV1+EAdaptationMinV1);//*tempF1.x
		
		float cgray=dot(color.xyz, float3(0.27, 0.67, 0.06));
		cgray=pow(cgray, EContrastV1);
		float3 poweredcolor=pow(color.xyz, EColorSaturationV1);
		float newgray=dot(poweredcolor.xyz, float3(0.27, 0.67, 0.06));
		color.xyz=poweredcolor.xyz*cgray/(newgray+0.0001);

		float3	luma=color.xyz;
		float	lumamax=300.0;
		color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV1);
	#endif
	//+++++++++++++++++++++++++++++
	
	//+++++++++++++++++++++++++++++
	#if (POSTPROCESS==2)
		grayadaptation=max(grayadaptation, 0.0);
		grayadaptation=min(grayadaptation, 50.0);
		color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2);//*tempF1.x

		//color.xyz*=EBrightnessV2;
		color.xyz+=0.000001;
		float3 xncol=normalize(color.xyz);
		float3 scl=color.xyz/xncol.xyz;
		scl=pow(scl, EIntensityContrastV2);
		xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
		color.xyz=scl*xncol.xyz;

		float	lumamax=EToneMappingOversaturationV2;
		color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
	#endif
	//+++++++++++++++++++++++++++++

	//+++++++++++++++++++++++++++++ HD6 version based on postprocess 2
	#if (POSTPROCESS==5)
			//grayadaptation=max(grayadaptation, 0.0);
			//grayadaptation=min(grayadaptation, 50.0);
			//color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2); //*tempF1.x		
		// HD6 - Screw eye adaptation it drives me mad, bright sky causes everything else to darken yuck
		// Human eye adaptation happens instantly or so slowly you dont notice it in reality
		// it would make sense if the game was calibrated for true brightness values of indoors and outdoors being 10000x brighter
		// but it isnt, and thus all the pseudo tone mapping and linear colorspace adaption shenanigans just drives me mad and for little gain
		// So now simple adjust brightness based on time of day
		// with all the other effects turned off this should roughly equal the brightness when ENB is disabled
		color.xyz*=lerp( hndtweak.x, hndtweak.y, hnd );

		float3 xncol=normalize(color.xyz);
		float3 scl=color.xyz/xncol.xyz;
		scl=pow(scl, EIntensityContrastV2);
		xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
		color.xyz=scl*xncol.xyz;
		color.xyz*=HCompensateSat; // compensate for darkening caused my EcolorSat above
		if (USE_TONE_OVERSAT && ! EInteriorFactor)
		{
			// Compensate the overwhelming sun and snow when USE_TONE_OVERSAT is enabled
			float etmv2 = EToneMappingOversaturationV2;
			float adaptLevel = tex2D(_s2, _v0).xyz;
			float adaptOffset = adaptLevel;
			if (adaptOffset < fAdaptMinLevel)
			{
				adaptOffset = 1.0 - (adaptOffset > 0 ? adaptOffset : 0);
			}
			etmv2 += etmv2 * (adaptLevel < 0.01 ? 0.01 : adaptLevel) * fEtmovsatMult;  // Raise EToneOversat value to compensate

			float	lumamax=etmv2 / (USE_ADAPT_OVERSAT ? adaptOffset : 1.0);
			color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV2);
		}
		else
		{
			color.xyz=color.xyz/(color.xyz + EToneMappingCurveV2);
		}
	#endif
	//+++++++++++++++++++++++++++++

	//+++++++++++++++++++++++++++++
	#if (POSTPROCESS==3)
		grayadaptation=max(grayadaptation, 0.0);
		grayadaptation=min(grayadaptation, 50.0);
		color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3); //*tempF1.x

		float	lumamax=EToneMappingOversaturationV3;
		color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV3);
	#endif
	//+++++++++++++++++++++++++++++

	//+++++++++++++++++++++++++++++
	#if (POSTPROCESS==4)
		grayadaptation=max(grayadaptation, 0.0);
		grayadaptation=min(grayadaptation, 50.0);
		color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV4+EAdaptationMinV4);

		float Y = dot(color.xyz, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
		float U = dot(color.xyz, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
		float V = dot(color.xyz, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
		
		Y=pow(Y, EBrightnessCurveV4);
		Y=Y*EBrightnessMultiplierV4;
			//Y=Y/(Y+EBrightnessToneMappingCurveV4);
			//float	desaturatefact=saturate(Y*Y*Y*1.7);
			//U=lerp(U, 0.0, desaturatefact);
			//V=lerp(V, 0.0, desaturatefact);
		color.xyz=V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;

		color.xyz=max(color.xyz, 0.0);
		color.xyz=color.xyz/(color.xyz+EBrightnessToneMappingCurveV4);
	#endif
	//+++++++++++++++++++++++++++++
	
	//+++++++++++++++++++++++++++++
	//pallete texture (0.082+ version feature)
	#ifdef E_CC_PALETTE
	   if (usePaletteMixer)	
	   {
		color.rgb=saturate(color.rgb);
		float3	brightness=Adaptation.xyz; //tex2D(_s4, 0.5); //adaptation luminance
			//brightness=saturate(brightness); //old version from ldr games
		brightness=(brightness/(brightness+1.0));//new version
		brightness=max(brightness.x, max(brightness.y, brightness.z));//new version
		float3	palette;
		float4	uvsrc=0.0;
		uvsrc.y=brightness.r;
		uvsrc.x=color.r;
		palette.r=tex2Dlod(_s7, uvsrc).r;
		uvsrc.x=color.g;
		uvsrc.y=brightness.g;
		palette.g=tex2Dlod(_s7, uvsrc).g;
		uvsrc.x=color.b;
		uvsrc.y=brightness.b;
		palette.b=tex2Dlod(_s7, uvsrc).b;		
		
		color.rgb=lerp( color.rgb, palette.rgb, palmix );
	   }
	#endif //E_CC_PALETTE
	//+++++++++++++++++++++++++++++

#ifdef E_CC_PROCEDURAL
	float	tempgray;
	float4	tempvar;
	float3	tempcolor;

	//+++ levels like in photoshop, including gamma, lightness, additive brightness
	color=max(color-ECCInBlack, 0.0) / max(ECCInWhite-ECCInBlack, 0.0001);
	if(EInteriorFactor)
	{
		if (ECCGammaInt!=1.0) color=pow(color, ECCGammaInt);
	}
	else
	{
		if (ECCGammaExt!=1.0) color=pow(color, ECCGammaExt);

	}
	color=color*(ECCOutWhite-ECCOutBlack) + ECCOutBlack;

	//+++ brightness
	color=color*ECCBrightness;

	//+++ contrast
	color=(color-ECCContrastGrayLevel) * ECCContrast + ECCContrastGrayLevel;

	//+++ saturation
	tempgray=dot(color, 0.3333);
	color=lerp(tempgray, color, ECCSaturation);

	//+++ desaturate shadows
	tempgray=dot(color, 0.3333);
	tempvar.x=saturate(1.0-tempgray);
	tempvar.x*=tempvar.x;
	tempvar.x*=tempvar.x;
	color=lerp(color, tempgray, ECCDesaturateShadows*tempvar.x);

	//+++ color balance
	color=saturate(color);
	tempgray=dot(color, 0.3333);
	float2	shadow_highlight=float2(1.0-tempgray, tempgray);
	shadow_highlight*=shadow_highlight;
	color.rgb+=(ECCColorBalanceHighlights*2.0-1.0)*color * shadow_highlight.x;
	color.rgb+=(ECCColorBalanceShadows*2.0-1.0)*(1.0-color) * shadow_highlight.y;

	//+++ channel mixer
	tempcolor=color;
	color.r=dot(tempcolor, ECCChannelMixerR);
	color.g=dot(tempcolor, ECCChannelMixerG);
	color.b=dot(tempcolor, ECCChannelMixerB);
#endif //E_CC_PROCEDURAL

	_oC0.w=1.0;
	_oC0.xyz=color.xyz;
#ifdef HD6_DEBUG	
	// HD6 - debug triangle - draws a triangle top left showing the value of night/day for testing
	//_oC0.xyz = _v0.x+_v0.y < 0.1 ? (hnd) : (_oC0.xyz);
	float h11 = h1 == 1 ? 0 : 0.4;
	_oC0.xyz += _v0.x+_v0.y < dotsize ? (h11) : (0);
	
	// Red dot in bottom left if you adjust daytime
	float h22 = h2 == 1 ? 0 : 0.4;
	_oC0.xyz += _v0.x+(1-_v0.y) < dotsize ? (h22) : (0);
	
	// White dot in top right if you adjust saturation
	float h33 = s1 == 1 ? 0 : 0.4;
	_oC0.xyz += (1-_v0.x)+_v0.y < dotsize ? (h33) : (0);
#endif	
	// [NOTE : Letterbox effect code (by Matso)]
	if (USE_LETTERBOX_EFFECT)
	{
		float offset = fLetterboxOffset * 0.01;
		if (IN.txcoord0.y <= offset || IN.txcoord0.y >= (1.0 - offset)) _oC0.rgb = 0.0;
	}

	return _oC0;
}



//switch between vanilla and mine post processing
technique Shader_D6EC7DD1 <string UIName="ENBSeries";>
{
	pass p0
	{
		VertexShader = compile vs_3_0 VS_Quad();
		PixelShader = compile ps_3_0 PS_D6EC7DD1();

		ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
		ZEnable=FALSE;
		ZWriteEnable=FALSE;
		CullMode=NONE;
		AlphaTestEnable=FALSE;
		AlphaBlendEnable=FALSE;
		SRGBWRITEENABLE=FALSE;
	}
}



//original shader of post processing
technique Shader_ORIGINALPOSTPROCESS <string UIName="Vanilla";>
{
	pass p0
	{
		VertexShader  = compile vs_3_0 VS_Quad();
		PixelShader=
	asm
	{
// Parameters:
//   sampler2D Avg;
//   sampler2D Blend;
//   float4 Cinematic;
//   float4 ColorRange;
//   float4 Fade;
//   sampler2D Image;
//   float4 Param;
//   float4 Tint;


// Registers:

//   Name         Reg   Size
//   ------------ ----- ----
//   ColorRange   c1       1
//   Param        c2       1
//   Cinematic    c3       1
//   Tint         c4       1
//   Fade         c5       1
//   Image        s0       1
//   Blend        s1       1
//   Avg          s2       1
//s0 bloom result
//s1 color
//s2 is average color

    ps_3_0
    def c6, 0, 0, 0, 0
    //was c0 originally
    def c7, 0.212500006, 0.715399981, 0.0720999986, 1
    dcl_texcoord v0.xy
    dcl_2d s0
    dcl_2d s1
    dcl_2d s2
    rcp r0.x, c2.y
    texld r1, v0, s2
    mul r0.yz, r1.xxyw, c1.y
    rcp r0.w, r0.y
    mul r0.z, r0.w, r0.z
    texld r1, v0, s1
    mul r1.xyz, r1, c1.y
    dp3 r0.w, c7, r1
    mul r1.w, r0.w, r0.z
    mad r0.z, r0.z, r0.w, c7.w
    rcp r0.z, r0.z
    mad r0.x, r1.w, r0.x, c7.w
    mul r0.x, r0.x, r1.w
    mul r0.x, r0.z, r0.x
    cmp r0.x, -r0.w, c6.x, r0.x
    rcp r0.z, r0.w
    mul r0.z, r0.z, r0.x
    add_sat r0.x, -r0.x, c2.x
    texld r2, v0, s0
    mul r2.xyz, r2, c1.y
    mul r2.xyz, r0.x, r2
    mad r1.xyz, r1, r0.z, r2
    dp3 r0.x, r1, c7
    mov r1.w, c7.w
    lrp r2, c3.x, r1, r0.x
    mad r1, r0.x, c4, -r2
    mad r1, c4.w, r1, r2
    mad r1, c3.w, r1, -r0.y
    mad r0, c3.z, r1, r0.y
    add r1, -r0, c5
    mad oC0, c5.w, r1, r0

	};
		ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
		ZEnable=FALSE;
		ZWriteEnable=FALSE;
		CullMode=NONE;
		AlphaTestEnable=FALSE;
		AlphaBlendEnable=FALSE;
		SRGBWRITEENABLE=FALSE;
    }
}
