////////////////////////////////////////////////
// ENBSeries Effect file //
// visit
http://enbdev.com for updates //
// Copyright (c) 2007-2012 Boris Vorontsov //
// Modified by Michael Tichenor (IndigoNeko) //
////////////////////////////////////////////////
// NOTE: This file is formatted to be viewed in Courier New font.
/////////////////////////
// DEFINES AND ENABLES //
/////////////////////////
// NOTE: To activate a feature, remove the two slashes in front of the #define. To deactivate it, add two slashes.
// #define DISABLE_COLOR_PROCESSING // Disable color processing (vanilla colors only).
#define ENABLE_VANILLA_COLOR // Enable vanilla color correction.
#define USE_VANILLA_BLOOM // Use vanilla bloom effect. See Vanilla Color Control settings below.
#define USE_VANILLA_ADAPTATION // Use vanilla adaptation effect. See Vanilla Color Control settings below.
#define ENABLE_ENB_PALETTE // Enable ENB Palette Mapping.
#define ENABLE_ENB_ADAPTATION // Enable ENB Adaptation.
#define ENABLE_ENB_BLOOM // Enable ENB Bloom.
#define USE_BLOOM_HSV // Use HSV color correction for bloom. See ENB Bloom settings below.
#define USE_BLOOM_LERP // Use interpolation for bloom, shifting the final colors towards the bloom colors.
// #define USE_BLOOM_ADD // Use addition for bloom, adding it to final color. WARNING: EXPERIMENTAL.
#define ENABLE_HSV // Enable HSV color correction. See HSV Color Correction settings below.
#define USE_HSV_SMOOTH // Use smoothstep color controls for overall color control.
#define USE_HSV_CURVE // Use power curve color controls for overall color control.
#define USE_HSV_EQUALIZER // Use Color Equalizer system for specific color control.
// #define ENABLE_LETTERBOX_BARS // Enable cinematic bars (black bars at top and bottom).
// #define ENABLE_INTERLACE_VERTICAL // Enable vertical interlacing (vertical striping).
// #define ENABLE_INTERLACE_HORIZONTAL // Enable horizontal interlacing (horizontal striping).
// #define ENABLE_VIGNETTE // Enable vignette effect (black ring around screen).
// #define ENABLE_SEPIATONE // Enable sepia tone effect (turns everything orange).
// #define ENABLE_GRAIN // Enable grain effect (puts speckles on screen).
//////////////////////////
// GLOBALS AND SETTINGS //
//////////////////////////
// Vanilla Color Correction settings.
float fVanillaBloom = 1.0; // Controls the amount of vanilla bloom effect. Default: 1.0.
float fVanillaAdaptationAmbient = 1.0; // Controls how much ambient luminosity there is from vanilla adaptation code.
float fVanillaAdaptationChange = 1.0; // Controls how much the brightness changes when looking up and down. Affects ambient too.
// ENB Bloom settings.
float fBloomIntensityMult = 1.0; // Controls brightness of bloom. Higher values are brighter.
float fBloomIntensityCurve = 1.0; // Controls brightness curve of bloom. Higher values make midranges darker.
float fBloomIntensitySmooth = 0.0; // Controls brightness contrast of bloom. Makes darks darker and brights brighter.
float fBloomIntensityMax = 3.0; // Controls brightness maximum of bloom.
float fBloomSaturationMult = 1.0; // Controls the saturation of bloom. Higher values are more colorful.
float fBloomSaturationCurve = 1.0; // Controls the saturation curve of bloom. Higher values reduce midrange colors.
float fBloomSaturationSmooth = 0.0; // Controls the saturation contrast of bloom. Reduces subtle coloring.
// HSV Color Correction settings.
// WARNING: Most users should ONLY change the fColorSaturationMult variable.
// HSV Daytime Settings
float fColorSaturationMultDay = 1.0; // Controls the color saturation multiplier. Range: 0.0 (greyscale) to 2.0 (hypercolor).
float fColorSaturationModDay = 0.0; // Controls the color saturation. Range: -1 to 1. Default: 0.0
float fColorSaturationCurveDay = 1.0; // Controls the color saturation curve. Default: 1.0.
float fColorSaturationSmoothDay = 0.0; // Controls the color saturation contrast. Default: 0.0.
float fColorIntensityMultDay = 1.0; // Controls the color intensity multiplier. Default: 1.0
float fColorIntensityModDay = 0.0; // Controls the color brightness. Range: -1 to 1. Default: 0.0
float fColorIntensityCurveDay = 1.0; // Controls the color intensity curve. Default: 1.0
float fColorIntensitySmoothDay = 0.0; // Controls the color intensity contrast. Default: 0.0.
float fColorHueMultDay = 1.0; // Controls the color hue multiplier. Default: 1.0
float fColorHueModDay = 0.0; // Controls the color hue. Range: -1 to 1. Default: 0.0
float fColorHueCurveDay = 1.0; // Controls the color hue curve. Default: 1.0.
float fColorHueSmoothDay = 0.0; // Controls the color hue contrast. Default: 0.0.
// HSV Nighttime Settings
float fColorSaturationMultNight = 1.0; // Controls the color saturation multiplier. Range: 0.0 (greyscale) to 2.0 (hypercolor).
float fColorSaturationModNight = 0.0; // Controls the color saturation. Range: -1 to 1. Default: 0.0
float fColorSaturationCurveNight = 1.0; // Controls the color saturation curve. Default: 1.0.
float fColorSaturationSmoothNight = 0.0; // Controls the color saturation contrast. Default: 0.0.
float fColorIntensityMultNight = 1.0; // Controls the color intensity multiplier. Default: 1.0
float fColorIntensityModNight = 0.0; // Controls the color brightness. Range: -1 to 1. Default: 0.0
float fColorIntensityCurveNight = 1.0; // Controls the color intensity curve. Default: 1.0
float fColorIntensitySmoothNight = 0.0; // Controls the color intensity contrast. Default: 0.0.
float fColorHueMultNight = 1.0; // Controls the color hue multiplier. Default: 1.0
float fColorHueModNight = 0.0; // Controls the color hue. Range: -1 to 1. Default: 0.0
float fColorHueCurveNight = 1.0; // Controls the color hue curve. Default: 1.0.
float fColorHueSmoothNight = 0.0; // Controls the color hue contrast. Default: 0.0.
// HSV Interior Settings
float fColorSaturationMultInterior = 1.0; // Controls the color saturation multiplier. Range: 0.0 (greyscale) to 2.0 (hypercolor).
float fColorSaturationModInterior = 0.0; // Controls the color saturation. Range: -1 to 1. Default: 0.0
float fColorSaturationCurveInterior = 1.0; // Controls the color saturation curve. Default: 1.0.
float fColorSaturationSmoothInterior = 0.0; // Controls the color saturation contrast. Default: 0.0.
float fColorIntensityMultInterior = 1.0; // Controls the color intensity multiplier. Default: 1.0
float fColorIntensityModInterior = 0.0; // Controls the color brightness. Range: -1 to 1. Default: 0.0
float fColorIntensityCurveInterior = 1.0; // Controls the color intensity curve. Default: 1.0
float fColorIntensitySmoothInterior = 0.0; // Controls the color intensity contrast. Default: 0.0.
float fColorHueMultInterior = 1.0; // Controls the color hue multiplier. Default: 1.0
float fColorHueModInterior = 0.0; // Controls the color hue. Range: -1 to 1. Default: 0.0
float fColorHueCurveInterior = 1.0; // Controls the color hue curve. Default: 1.0.
float fColorHueSmoothInterior = 0.0; // Controls the color hue contrast. Default: 0.0.
// HSV Equalizer settings.
// Adjust multiplier and modifier of specific color saturations. Default: 0.0
float fColorSaturationMultRed = 0.0;
float fColorSaturationMultOrange = 0.0;
float fColorSaturationMultYellow = 0.0;
float fColorSaturationMultGreen = 0.0;
float fColorSaturationMultCyan = 0.0;
float fColorSaturationMultBlue = 0.0;
float fColorSaturationMultMagenta = 0.0;
float fColorSaturationModRed = 0.0;
float fColorSaturationModOrange = 0.0;
float fColorSaturationModYellow = 0.0;
float fColorSaturationModGreen = 0.0;
float fColorSaturationModCyan = 0.0;
float fColorSaturationModBlue = 0.0;
float fColorSaturationModMagenta = 0.0;
// Letterbox settings.
float fLetterboxBarHeight = 0.1; // Controls the height of cinematic bars. Default: 0.1.
// Interlace settings.
float fInterlaceVerticalWidth = 1.0; // Controls the width of interlace bars in pixels. Default: 1.0.
float fInterlaceHorizontalWidth = 1.0; // Controls the width of interlace bars in pixels. Default: 1.0.
// Vignette settings.
float fVignetteRadius = 0.7; // Controls how large the radius of the vignette is. Larger numbers make the ring larger.
float fVignetteSharpness = 0.1; // Controls how sharp the edge of the vignette is. Larger numbers make edge of the ring sharper.
float fVignetteCurve = 2.0; // Controls the blending of the vignette.
float2 fVignetteCenter = float2( 0.5, 0.5 ); // Controls the position of the vignette center on the screen.
float2 fVignetteScale = float2( 1.0, 1.0 ); // Controls the horizontal and vertical scaling of vignette.
// Sepia Tone settings.
float3 fSepiaColor = float3( 1.0, 0.85 , 0.7 ); // Controls color of sepia tone.
float fSepiaDesaturation = 0.7; // Controls amount of sepia color applied to image.
float fSepiaExposure = 1.2; // Controls exposure of sepia tone.
// Grain settings.
float fGrainIntensity = 1.0; // Controls the intensity of the grain effect.
float fGrainSaturation = 0.0; // Controls the color saturation of the grain effect.
float fGrainMotion = 0.05; // Controls how rapidly the grain effect changes over time.
//////////////////////////////////////////////
// DO NOT MODIFY ANYTHING BELOW THIS LINE, //
// UNLESS YOU KNOW HLSL SHADER PROGRAMMING. //
//////////////////////////////////////////////
// List of floating point values for hues, used in equalizer.
float fHueRed = 0.0;
float fHueOrange = 0.08333333;
float fHueYellow = 0.16666667;
float fHueGreen = 0.33333333;
float fHueCyan = 0.5;
float fHueBlue = 0.66666667;
float fHueMagenta = 0.83333333;
float fHueRed2 = 1.0;
///////////////
// FUNCTIONS //
///////////////
float ColorEqualizerMult(in float H)
{
float SMult = 1.0;
SMult += fColorSaturationMultRed * ( 1.0 - min( 1.0, abs( ( fHueRed - H ) / ( fHueRed - fHueOrange ) ) ) );
SMult += fColorSaturationMultOrange * ( 1.0 - min( 1.0, abs( ( fHueOrange - H ) / ( fHueOrange - fHueYellow ) ) ) );
SMult += fColorSaturationMultYellow * ( 1.0 - min( 1.0, abs( ( fHueYellow - H ) / ( fHueYellow - fHueGreen ) ) ) );
SMult += fColorSaturationMultGreen * ( 1.0 - min( 1.0, abs( ( fHueGreen - H ) / ( fHueGreen - fHueYellow ) ) ) );
SMult += fColorSaturationMultCyan * ( 1.0 - min( 1.0, abs( ( fHueCyan - H ) / ( fHueCyan - fHueGreen ) ) ) );
SMult += fColorSaturationMultBlue * ( 1.0 - min( 1.0, abs( ( fHueBlue - H ) / ( fHueBlue - fHueCyan ) ) ) );
SMult += fColorSaturationMultMagenta * ( 1.0 - min( 1.0, abs( ( fHueMagenta - H ) / ( fHueMagenta - fHueBlue ) ) ) );
SMult += fColorSaturationMultRed * ( 1.0 - min( 1.0, abs( ( fHueRed2 - H ) / ( fHueRed2 - fHueMagenta ) ) ) );
return SMult;
}
float ColorEqualizerMod(in float H)
{
float SMod = 0.0;
SMod += fColorSaturationModRed * ( 1.0 - min( 1.0, abs( ( fHueRed - H ) / ( fHueRed - fHueOrange ) ) ) );
SMod += fColorSaturationModOrange * ( 1.0 - min( 1.0, abs( ( fHueOrange - H ) / ( fHueOrange - fHueYellow ) ) ) );
SMod += fColorSaturationModYellow * ( 1.0 - min( 1.0, abs( ( fHueYellow - H ) / ( fHueYellow - fHueGreen ) ) ) );
SMod += fColorSaturationModGreen * ( 1.0 - min( 1.0, abs( ( fHueGreen - H ) / ( fHueGreen - fHueYellow ) ) ) );
SMod += fColorSaturationModCyan * ( 1.0 - min( 1.0, abs( ( fHueCyan - H ) / ( fHueCyan - fHueGreen ) ) ) );
SMod += fColorSaturationModBlue * ( 1.0 - min( 1.0, abs( ( fHueBlue - H ) / ( fHueBlue - fHueCyan ) ) ) );
SMod += fColorSaturationModMagenta * ( 1.0 - min( 1.0, abs( ( fHueMagenta - H ) / ( fHueMagenta - fHueBlue ) ) ) );
SMod += fColorSaturationModRed * ( 1.0 - min( 1.0, abs( ( fHueRed2 - H ) / ( fHueRed2 - fHueMagenta ) ) ) );
return SMod;
}
float3 HUEtoRGB(in float H)
{
float R = abs(H * 6.0 - 3.0) - 1.0;
float G = 2.0 - abs(H * 6.0 - 2.0);
float B = 2.0 - abs(H * 6.0 - 4.0);
return saturate(float3(R,G,B));
}
float RGBCVtoHUE(in float3 RGB, in float C, in float V)
{
float3 Delta = (V - RGB) / C;
Delta.rgb -= Delta.brg;
Delta.rgb += float3(2.0,4.0,6.0);
Delta.brg = step(V, RGB) * Delta.brg;
float H;
H = max(Delta.r, max(Delta.g, Delta.b));
return frac(H / 6.0);
}
float3 HSVtoRGB(in float3 HSV)
{
float3 RGB = HUEtoRGB(HSV.x);
return ((RGB - 1) * HSV.y + 1) * HSV.z;
}
float3 RGBtoHSV(in float3 RGB)
{
float3 HSV = 0.0;
HSV.z = max(RGB.r, max(RGB.g, RGB.b));
float M = min(RGB.r, min(RGB.g, RGB.b));
float C = HSV.z - M;
if (C != 0.0)
{
HSV.x = RGBCVtoHUE(RGB, C, HSV.z);
HSV.y = C / HSV.z;
}
return HSV;
}
float random(in float2 uv)
{
float2 noise = (frac(sin(dot(uv , float2(12.9898,78.233) * 2.0)) * 43758.5453));
return abs(noise.x + noise.y) * 0.5;
}
float smootherstep(float edge0, float edge1, float x)
{
x = saturate((x - edge0)/(edge1 - edge0));
return x*x*(3 - 2*x);
}
/////////////////////////////
// Code by Boris Vorontsov //
/////////////////////////////
//keyboard controlled temporary variables. 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
float4 Timer; //x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
float4 ScreenSize; //x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
float ENightDayFactor; //changes in range 0..1, 0 means that night time, 1 - day time
float EInteriorFactor; //changes 0 or 1. 0 means that exterior, 1 - interior
float EBloomAmount; //enb version of bloom applied, ignored if original post processing used
float EAdaptationMin=0.0; // Controls the minimum for ENB adaptation code. Default: 0.0.
float EAdaptationMax=1.0; // Controls the maximum for ENB adaptation code. Default: 1.0.
//////////////
// TEXTURES //
//////////////
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;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D _s2 = sampler_state
{
Texture = <texs2>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D _s3 = sampler_state
{
Texture = <texs3>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
sampler2D _s4 = sampler_state
{
Texture = <texs4>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
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;
};
/////////////
// SHADERS //
/////////////
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;
}
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;
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;
////////////////////
// LETTERBOX CODE //
////////////////////
#ifdef ENABLE_LETTERBOX_BARS
if( IN.txcoord0.y > 1.0 - fLetterboxBarHeight || IN.txcoord0.y < fLetterboxBarHeight )
{
return _c6;
}
#endif
////////////////////
// INTERLACE CODE //
////////////////////
#ifdef ENABLE_INTERLACE_VERTICAL
float InterlaceVerticalScalar = 0.5 / max( 1.0, floor( fInterlaceVerticalWidth ) );
if( frac( IN.txcoord0.x * ScreenSize.x * InterlaceVerticalScalar ) > 0.5 )
{
return _c6;
}
#endif
#ifdef ENABLE_INTERLACE_HORIZONTAL
float InterlaceHorizontalScalar = 0.5 / max( 1.0, floor( fInterlaceHorizontalWidth ) );
if( frac( IN.txcoord0.y * ScreenSize.x * ScreenSize.w * InterlaceHorizontalScalar ) > 0.5 )
{
return _c6;
}
#endif
//////////////////////////////////////////
// VANILLA SKYRIM COLOR CORRECTION CODE //
//////////////////////////////////////////
float4 _v0=0.0;
_v0.xy=IN.txcoord0.xy;
// DEBUG OUTPUT
// return tex2D( _s0, _v0 );
#ifdef ENABLE_VANILLA_COLOR
r0.x=1.0 / _c2.y;
#ifdef USE_VANILLA_ADAPTATION
r1=tex2D(_s2, _v0);
r1.x = lerp( 0.2, r1.x, fVanillaAdaptationAmbient );
r1.y = lerp( r1.x, r1.y, fVanillaAdaptationChange );
r0.yz=r1.xy * _c1.y;
#endif
#ifndef USE_VANILLA_ADAPTATION
r1.x = 0.2;
r1.y = 0.2;
r0.yz=r1.xy * _c1.y;
#endif
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);
#ifdef USE_VANILLA_BLOOM
r2=tex2D(_s1, _v0) * fVanillaBloom;
#endif
#ifndef USE_VANILLA_BLOOM
r2 = 0.0;
#endif
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;
r0=_c3.z * r1 + r0.y;
r1=-r0 + _c5;
_oC0=_c5.w * r1 + r0;
#endif
#ifndef ENABLE_VANILLA_COLOR
_oC0 = tex2D(_s0, _v0);
#endif
float4 color = _oC0;
// DEBUG OUTPUT
// return color;
////////////////////
// ENB BLOOM CODE //
////////////////////
#ifdef ENABLE_ENB_BLOOM
float4 enbbloomcol = tex2D( _s3, _v0.xy );
// DEBUG OUTPUT
// return enbbloomcol;
if( enbbloomcol.r + enbbloomcol.g + enbbloomcol.b > 0.0 )
{
#ifdef USE_BLOOM_HSV
float3 bloomhsv = RGBtoHSV( enbbloomcol.rgb );
bloomhsv.y = lerp( bloomhsv.y, smoothstep( 0.0, 1.0, bloomhsv.y ), fBloomSaturationSmooth );
bloomhsv.y = pow( bloomhsv.y, fBloomSaturationCurve );
bloomhsv.y *= fBloomSaturationMult;
bloomhsv.z = lerp( bloomhsv.z, smoothstep( 0.0, 1.0, bloomhsv.z ), fBloomIntensitySmooth );
bloomhsv.z = pow( bloomhsv.z, fBloomIntensityCurve );
bloomhsv.z *= fBloomIntensityMult;
bloomhsv.z = clamp( bloomhsv.z, 0.0, fBloomIntensityMax );
enbbloomcol.rgb = HSVtoRGB( bloomhsv );
#endif
#ifdef USE_BLOOM_LERP
color.rgb = lerp( color.rgb, enbbloomcol.rgb, clamp( EBloomAmount, 0.0, 1.0 ) );
#endif
#ifdef USE_BLOOM_ADD
color.rgb += enbbloomcol.rgb * clamp( EBloomAmount, 0.0, 1.0 );
#endif
}
#endif
// DEBUG OUTPUT
// return color;
/////////////////////////
// ENB ADAPTATION CODE //
/////////////////////////
float4 Adaptation = tex2D(_s4, 0.5);
#ifdef ENABLE_ENB_ADAPTATION
float grayadaptation = max(max(Adaptation.x, Adaptation.y), Adaptation.z);
grayadaptation = max(grayadaptation, 0.0);
grayadaptation = min(grayadaptation, 50.0);
color.xyz = color.xyz / (grayadaptation * EAdaptationMax + EAdaptationMin);
#endif
// DEBUG OUTPUT
// return color;
///////////////////////////////
// HSV COLOR CORRECTION CODE //
///////////////////////////////
#ifdef ENABLE_HSV
// NOTE: Apparently Boris has his interior factor values swapped: 0 = interior, 1 = exterior.
float fInteriorFactor = 1.0 - EInteriorFactor;
float fColorHueSmooth =lerp( lerp( fColorHueSmoothNight, fColorHueSmoothDay, ENightDayFactor ), fColorHueSmoothInterior, fInteriorFactor );
float fColorSaturationSmooth =lerp( lerp( fColorSaturationSmoothNight, fColorSaturationSmoothDay, ENightDayFactor ), fColorSaturationSmoothInterior, fInteriorFactor );
float fColorIntensitySmooth =lerp( lerp( fColorIntensitySmoothNight, fColorIntensitySmoothDay, ENightDayFactor ), fColorIntensitySmoothInterior, fInteriorFactor );
float fColorHueCurve =lerp( lerp( fColorHueCurveNight, fColorHueCurveDay, ENightDayFactor ), fColorHueCurveInterior, fInteriorFactor );
float fColorSaturationCurve =lerp( lerp( fColorSaturationCurveNight, fColorSaturationCurveDay, ENightDayFactor ), fColorSaturationCurveInterior, fInteriorFactor );
float fColorIntensityCurve =lerp( lerp( fColorIntensityCurveNight, fColorIntensityCurveDay, ENightDayFactor ), fColorIntensityCurveInterior, fInteriorFactor );
float fColorHueMult =lerp( lerp( fColorHueMultNight, fColorHueMultDay, ENightDayFactor ), fColorHueMultInterior, 1.0 - fInteriorFactor );
float fColorSaturationMult =lerp( lerp( fColorSaturationMultNight, fColorSaturationMultDay, ENightDayFactor ), fColorSaturationMultInterior, fInteriorFactor );
float fColorIntensityMult =lerp( lerp( fColorIntensityMultNight, fColorIntensityMultDay, ENightDayFactor ), fColorIntensityMultInterior, fInteriorFactor );
float fColorHueMod =lerp( lerp( fColorHueModNight, fColorHueModDay, ENightDayFactor ), fColorHueModInterior, fInteriorFactor );
float fColorSaturationMod =lerp( lerp( fColorSaturationModNight, fColorSaturationModDay, ENightDayFactor ), fColorSaturationModInterior, fInteriorFactor );
float fColorIntensityMod =lerp( lerp( fColorIntensityModNight, fColorIntensityModDay, ENightDayFactor ), fColorIntensityModInterior, fInteriorFactor );
float3 hsvcolor = RGBtoHSV( color.xyz );
hsvcolor.y = max( hsvcolor.y, 0.0 );
hsvcolor.z = max( hsvcolor.z, 0.0 );
#ifdef USE_HSV_SMOOTH
hsvcolor.x = lerp( hsvcolor.x, smoothstep( 0.0, 1.0, hsvcolor.x ), fColorHueSmooth );
hsvcolor.y = lerp( hsvcolor.y, smoothstep( 0.0, 1.0, hsvcolor.y ), fColorSaturationSmooth );
hsvcolor.z = lerp( hsvcolor.z, smoothstep( 0.0, 1.0, hsvcolor.z ), fColorIntensitySmooth );
#endif
#ifdef USE_HSV_CURVE
hsvcolor.x = pow( hsvcolor.x, fColorHueCurve );
hsvcolor.y = pow( hsvcolor.y, fColorSaturationCurve );
hsvcolor.z = pow( hsvcolor.z, fColorIntensityCurve );
#endif
hsvcolor.x = fColorHueMod + ( fColorHueMult * hsvcolor.x );
hsvcolor.y = fColorSaturationMod + ( fColorSaturationMult * hsvcolor.y );
hsvcolor.z = fColorIntensityMod + ( fColorIntensityMult * hsvcolor.z );
#ifdef USE_HSV_EQUALIZER
hsvcolor.y = ColorEqualizerMod( hsvcolor.x ) + ( ColorEqualizerMult( hsvcolor.x ) * hsvcolor.y );
#endif
hsvcolor.y = max( hsvcolor.y, 0.0 );
hsvcolor.z = max( hsvcolor.z, 0.0 );
color.xyz = HSVtoRGB( hsvcolor );
#endif
// DEBUG CODE
// return color;
//////////////////////
// ENB PALETTE CODE //
//////////////////////
#ifdef ENABLE_ENB_PALETTE
float3 enbpalcol = tex2D( _s7, 0.5 ).rgb;
float enbpallum = ( enbpalcol.r + enbpalcol.g + enbpalcol.b );
if( enbpallum > 0.0 )
{
color.rgb = saturate(color.rgb);
float3 brightness = Adaptation.xyz;
brightness=max(brightness.x, max(brightness.y, brightness.z));
float3 palette=0.0;
float4 uvsrc=0.0;
uvsrc.x=color.r;
uvsrc.y=brightness.r;
palette.r=tex2D(_s7, uvsrc).r;
uvsrc.x=color.g;
uvsrc.y=brightness.g;
palette.g=tex2D(_s7, uvsrc).g;
uvsrc.x=color.b;
uvsrc.y=brightness.b;
palette.b=tex2D(_s7, uvsrc).b;
color.rgb=palette.rgb;
}
#endif
// DEBUG CODE
// return color;
/////////////////////
// SEPIA TONE CODE //
/////////////////////
#ifdef ENABLE_SEPIATONE
float SepiaWeight = float3( 0.2125, 0.7154, 0.0721 );
float SepiaLuminance = min( 1.0, dot( color, SepiaWeight ) * fSepiaExposure ) ;
float3 SepiaColor = fSepiaColor * SepiaLuminance;
color.rgb = lerp( color.rgb, SepiaColor, fSepiaDesaturation );
#endif
////////////////
// GRAIN CODE //
////////////////
#ifdef ENABLE_GRAIN
float GrainTimerSeed = Timer.x * fGrainMotion;
float2 GrainTexCoordSeed = _v0.xy * 1.0;
float2 GrainSeed1 = GrainTexCoordSeed + float2( 0.0, GrainTimerSeed );
float2 GrainSeed2 = GrainTexCoordSeed + float2( GrainTimerSeed, 0.0 );
float2 GrainSeed3 = GrainTexCoordSeed + float2( GrainTimerSeed, GrainTimerSeed );
float GrainNoise1 = random( GrainSeed1 );
float GrainNoise2 = random( GrainSeed2 );
float GrainNoise3 = random( GrainSeed3 );
float GrainNoise4 = ( GrainNoise1 + GrainNoise2 + GrainNoise3 ) * 0.333333333;
float3 GrainNoise = float3( GrainNoise4, GrainNoise4, GrainNoise4 );
float3 GrainColor = float3( GrainNoise1, GrainNoise2, GrainNoise3 );
color.rgb += ( lerp( GrainNoise, GrainColor, fGrainSaturation ) * fGrainIntensity ) - ( fGrainIntensity * 0.5);
#endif
///////////////////
// VIGNETTE CODE //
///////////////////
#ifdef ENABLE_VIGNETTE
float2 VignettePosition = ( _v0.xy - fVignetteCenter ) * float2( ScreenSize.z, 1.0 );
VignettePosition /= fVignetteScale;
float VignetteDistance = distance( VignettePosition, float2(0.0 , 0.0) );
float VignetteEffect = max( 0.0, ( VignetteDistance - fVignetteRadius ) * fVignetteSharpness * 50.0 );
color.rgb *= max( 0.0, min( 1.0, 1.0 - pow( VignetteEffect, fVignetteCurve ) ) );
#endif
_oC0.w=1.0;
_oC0.xyz=color.xyz;
return _oC0;
}
#ifndef DISABLE_COLOR_PROCESSING
technique Shader_D6EC7DD1
#else
technique Shader_ORIGINALPOSTPROCESS
#endif
{
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
#ifndef DISABLE_COLOR_PROCESSING
technique Shader_ORIGINALPOSTPROCESS
#else
technique Shader_D6EC7DD1
#endif
{
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;
}
}