//These variables will get set automatically
texture tex1;
texture tex2;
//float2 rcpres;
float CurrentEye;
//float CurrentBrightness;
sampler s0 = sampler_state { AddressU = Clamp; AddressV = Clamp; texture = <tex1>; };
sampler s1 = sampler_state { texture = <tex2>; };
//Use these to modify the behaviour of the dll
bool SinglePixel=false;
bool AffectMenus=false;
int ToggleKey=107;
int ToggleSinglePixelKey=109;
int ToggleAffectMenusKey=106;
float ReactionSpeed=0.95;
//Current Settings
static const float BloomScale = 0.65;
static const float HDRScale = -0.38;
static const float HDRAdjust = -0.10;
//rcpres must be set to the reciprical of your screen resolution
//static const float2 rcpres = { 0.0015625, 0.0020833333333 }; //640x480
//static const float2 rcpres = { 0.00125, 0.0016666666667 }; //800x600
//static const float2 rcpres = { 0.0009765625, 0.0013020833 }; //1024x768
//static const float2 rcpres = { 0.000625, 0.0008333333333 }; //1600x1200
static const float2 rcpres = { 0.00078125, 0.0009765625 }; //1280x1024
float2 PixelKernelH[13] =
{
{ -6, 0 },
{ -5, 0 },
{ -4, 0 },
{ -3, 0 },
{ -2, 0 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ 2, 0 },
{ 3, 0 },
{ 4, 0 },
{ 5, 0 },
{ 6, 0 },
};
float2 PixelKernelV[13] =
{
{ 0, -6 },
{ 0, -5 },
{ 0, -4 },
{ 0, -3 },
{ 0, -2 },
{ 0, -1 },
{ 0, 0 },
{ 0, 1 },
{ 0, 2 },
{ 0, 3 },
{ 0, 4 },
{ 0, 5 },
{ 0, 6 },
};
static const float BlurWeights[13] =
{
0.002216,
0.008764,
0.026995,
0.064759,
0.120985,
0.176033,
0.199471,
0.176033,
0.120985,
0.064759,
0.026995,
0.008764,
0.002216,
};
float4 Bloom( in float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color = tex2D( s0, Tex );
float tempHDRScale=(0.70*smoothstep(0.00,0.75,CurrentEye))+HDRSc ale;
float4 Color2=0;
for (int i = 0; i < 13; i++)
{
Color2 += tex2D( s1, Tex + (PixelKernelH[i]*rcpres) ) * BlurWeights[i];
Color2 += tex2D( s1, Tex + (PixelKernelV[i]*rcpres) ) * BlurWeights[i];
}
float4 Curvemod = (0.70*Color);
Color = clamp((0.30*Color)+((0.70-Curvemod+tempHDRScale)*pow(Color,2))+((Curvemod-tempHDRScale)*(1-pow((1-Color),2))),0,1);
Color2 *= (BloomScale-(0.00*CurrentEye));
return clamp(Color + Color2,0,1);
}
float4 HDRBrightPass( in float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 color = tex2D( s0, Tex );
float tempbright = clamp((0.27*color[1])+(0.67*color[2])+(0.06*color[3]),0,1);
float HDRAdjustBias = (0.18*pow((1-CurrentEye),3));
float curvemod = (0.25*tempbright);
float4 colorbias = (1-pow((1-color),2));
float4 adjust = clamp(((color-CurrentEye)-HDRAdjust-(HDRAdjustBias)),0,1);
color = clamp((8*pow(adjust,5)),0,1);
//color += clamp(tex2D( s1, Tex ) - (2*(CurrentEye + 0.10)) ,0,0.75); //Uncomment this line for retina burn
color = clamp(((1-curvemod+HDRAdjustBias)*color)+((curvemod-HDRAdjustBias)*colorbias),0,1);
color.a = 1;
return color;
}
technique T0
{
pass p0 { PixelShader = compile ps_2_0 HDRBrightPass(); }
pass p1 { PixelShader = compile ps_2_0 Bloom(); }
}