Professional Documents
Culture Documents
// M A S T E R E F F E C T 1.0 //
// effect.txt shader file for GTA San Andreas //
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
// made by : Marty McFly //
// Original Codes & Shaders by: //
// Matso, Ceejay.dk, SSontech, icelaglace, AAA //
// Reinhard, HeliosDoubleSix, PetkaGtA, DKT70 //
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
//////////////////////////////////-------------------------------------------------
----------------]
/*-----------------------------------------------------------.
/ Choose effects /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ TVLevels settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Border settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Colorwashout settings /
'-----------------------------------------------------------*/
float ColorSaturation=0.5;
float ColorWashoutThreshold=0.85;
float ColorWashoutPow=1.0;
float ColorWashoutAmount=1.0;
float ColorDullnessAmount=0.5;
float ExpAdjustment=1.2;
/*-----------------------------------------------------------.
/ Anamorphic flare settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Noise settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Dither settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Vibrance settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Chromatic Abberation settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ FXAA settings /
'-----------------------------------------------------------*/
#define FXAA_LINEAR 0
#define FXAA_QUALITY__EDGE_THRESHOLD (1.0/16.0)
#define FXAA_QUALITY__EDGE_THRESHOLD_MIN (1.0/16.0)
#define FXAA_QUALITY__SUBPIX_CAP (3.0/4.0)
#define FXAA_QUALITY__SUBPIX_TRIM (1.0/4.0)
#define FXAA_QUALITY__SUBPIX_TRIM_SCALE (1.0/(1.0 - FXAA_QUALITY__SUBPIX_TRIM))
#define FXAA_SEARCH_STEPS 8
#define FXAA_SEARCH_THRESHOLD (1.0/4.0)
/*-----------------------------------------------------------.
/ HDR + Sharpen settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Old anamorphic flare settings /
'-----------------------------------------------------------*/
//the flares work differently so there are different values for the Threshold and
power needed.
const float fBlurSize = 1.0/384.0; //How big the flare appears, don't
go too high or it will look ugly
const float fBlurDownsampling = 128; //Something IDK, remained
from Petka work, only change in powers of 2 like 16, 32, 64 etc.
/*-----------------------------------------------------------.
/ Colormod-like bloom settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Light Scattering settings ("Godrays") /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Filmicpass settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Reinhard tonemap settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ PetkaGtA DOF settings /
'-----------------------------------------------------------*/
float ScreenScaleY;
float ScreenSize;
float PI = 3.14159265;
float2 texel = {0.0009765625,0.00130208333333333333333333333333};
//DOF params
float focalDepth = 90.5;
float focalLength = 80.5;
float fstop = 90.5;
bool manualdof = false; //manual dof calculation
float ndofstart = 1.0; //near dof blur start
float ndofdist = 2.0; //near dof blur falloff distance
float fdofstart = 1.0; //far dof blur start
float fdofdist = 3.0; //far dof blur falloff distance
bool autofocus = true;
float2 focus = float2(0.5,0.5);
float CoC = 0.100; //Circle of confusion
http://en.wikipedia.org/wiki/Circle_of_confusion
bool noise = false; //DOF noise, adds grain
float namount = 0.0000; //grain amount
float DOFdownsample = 4;
float maxblur = 4.0; //Power of DOF blur
static const int samples = 6; //more samples =better
quality but also less fps
static const int rings = 2; //ring count, DO NOT GO BEYOND 2 OR
GAME CRASH!!!
float threshold = 4.0; //threshold for gain
float gain =16.0; //brightens blurred areas to make bokeh
effect visible
float bias = 0.0;
float fringe = 0.0;
float znear = 20.0; //camera clipping start (blur
start)
float zfar = 2000.0; //camera clipping end (distance
beyond which blur doesn't get bigger anymore)
bool pentagon = false; //use pentagon as bokeh shape?
Bugged!
float feather = 10.0; //pentagon shape feather
/*-----------------------------------------------------------.
/ Gamma settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Filmiccurve settings /
'-----------------------------------------------------------*/
float FilmicExposure = 7;
//configuring the following stuff is very difficult, let it stay like this
//explanation is senseless because only the most advanced coders really understand
//what each value does (not even me), maybe only the author. Set one to 10 and look
what happens
//is the best way to get its effect
float3 Uncharted2Tonemap(float3 x)
{
return ((x*(ShoulderStrength*x+LinearAngle*LinearStrength)
+ToeStrength*ToeNumerator)/(x*(ShoulderStrength*x+LinearStrength)
+ToeStrength*ToeDenominator))-ToeNumerator/ToeDenominator;
}
/*-----------------------------------------------------------.
/ HD6 Vignette settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Standard Vignette settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Crossprocess settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ color mood/crossice settings /
'-----------------------------------------------------------*/
/*-----------------------------------------------------------.
/ Color Grading settings /
'-----------------------------------------------------------*/
//////////////////////////////////-------------------------------------------------
----------------]
//////////////////////////////////////////////
// DO NOT MODIFY ANYTHING BELOW THIS LINE, //
// UNLESS YOU KNOW HLSL SHADER PROGRAMMING. //
//////////////////////////////////////////////
//////////////////////////////////-------------------------------------------------
----------------]
//#define COLORCORRMAIN
#ifdef HSVULTIMATE
// List of floating point values for hues, used in equalizer.
float HueRed = 0.0;
float HueOrange = 0.08333333;
float HueYellow = 0.16666667;
float HueGreen = 0.33333333;
float HueCyan = 0.5;
float HueBlue = 0.66666667;
float HueMagenta = 0.83333333;
float HueRed2 = 1.0;
#ifdef FILMICPASS
float GetLuminance(float3 sample)
{
return dot(sample.xyz, 0.333);
}
float4 FilmPass(float4 B)
{
float4 G = B;
float4 H = 0.01;
B = pow(abs(B), Linearization);
B = lerp(H, B, Contrast);
float A = GetLuminance(B.rgb);
float4 D = A;
float a = RedCurve;
float b = GreenCurve;
float c = BlueCurve;
float d = BaseCurve;
float4 C = B;
float4 Di = 1.0 - D;
float4 iF = F;
float N = GetLuminance(F.rgb);
float4 Cn = F;
if (N < 0.5)
Cn = (2.0 * N - 1.0) * (F - F * F) + F;
else
Cn = (2.0 * N - 1.0) * (sqrt(F) - F) + F;
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
//---------------------------------------------------------------------------------
-----
// Vertex Shader Input
//---------------------------------------------------------------------------------
-----
float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
OUT.vpos=pos;
OUT.txcoord.xy=IN.txcoord.xy;
return OUT;
}
//---------------------------------------------------------------------------------
-----
// Pixel Shader
//---------------------------------------------------------------------------------
-----
return float2(noiseX,noiseY);
}
#ifdef NOISE
#ifdef HSVULTIMATE
#ifdef ENABLE_HSV_CONVERSION
float3 hsvcolor = RGBtoHSV( color.xyz );
#ifdef ENABLE_POW_CURVE
#ifdef ENABLE_HUE_ADJUSTMENT
hsvcolor.x = EColorHueMod + ( EColorHueMult * pow( hsvcolor.x, EColorHuePow ) );
#endif
#ifdef ENABLE_SATURATION_ADJUSTMENT
hsvcolor.y = EColorSaturationMod + ( EColorSaturationMult * pow( hsvcolor.y,
EColorSaturationPow ) );
#endif
#ifdef ENABLE_INTENSITY_ADJUSTMENT
hsvcolor.z = EColorIntensityMod + ( EColorIntensityMult * pow( hsvcolor.z,
EColorIntensityPow ) );
#endif
#ifdef ENABLE_COLOR_EQUALIZER
hsvcolor.y = ColorEqualizerMod( hsvcolor.x ) + ( ColorEqualizerMult( hsvcolor.x ) *
pow( hsvcolor.y, ColorEqualizerPow( hsvcolor.x ) ) );
#endif
#endif
#ifndef ENABLE_POW_CURVE
#ifdef ENABLE_HUE_ADJUSTMENT
hsvcolor.x = EColorHueMod + ( EColorHueMult * hsvcolor.x );
#endif
#ifdef ENABLE_SATURATION_ADJUSTMENT
hsvcolor.y = EColorSaturationMod + ( EColorSaturationMult * hsvcolor.y );
#endif
#ifdef ENABLE_INTENSITY_ADJUSTMENT
hsvcolor.z = EColorIntensityMod + ( EColorIntensityMult * hsvcolor.z );
#endif
#ifdef ENABLE_COLOR_EQUALIZER
hsvcolor.y = ColorEqualizerMod( hsvcolor.x ) + ( ColorEqualizerMult( hsvcolor.x ) *
hsvcolor.y );
#endif
#endif
#ifdef GAMMACORRECTION
color = pow(color, 1/GammaAmount);
#endif
#ifdef COLORCORRMAIN
color.r = (color.r)*(0.05 + 1.0f) + (color.g + color.b)*(-0.04);
color.g = (color.g)*(0.06 + 1.0f) + (color.r + color.b)*(-0.04);
color.b = (color.b)*(0.055 + 1.0f) + (color.r + color.g)*(-0.04);
#ifdef COLORCORRMAIN
color = saturate(color);
color = 1 - (0.97 - 0.065)*(1.04 - color);
color = saturate(color);
color = color + (0.82f / 2.0 - 0.5) * (1.0 - color);
color = saturate(color);
color.rgb = pow(0.85f * color, 1.0 / 0.95f);
#ifdef FILMICCURVE
float3 curr = Uncharted2Tonemap(color);
float3 whiteScale = Uncharted2Tonemap(FilmWeight);
color.xyz = curr*whiteScale;
color = pow(color, 0.55);
color = color*FilmicExposure;
#endif
#ifdef REINHARD_ICE21
float pixelLumi = dot(color.xyz, LUM_FACTOR.xyz);
float toneMapCalc = pixelLumi / (pixelLumi + 1);
color = toneMapCalc * pow(color / pixelLumi, REINHARD_SAT);
color = color * TONEMAPEXP;
#endif
#ifdef CROSSPROCESS
image1 +=CrossBrightness;
image1 *=1.2;
#endif
#ifdef CROSSICE
float Weight;
float4 colInput = color;
float4 colMood = 1.0f;
colMood.r = moodR;
colMood.g = moodG;
colMood.b = moodB;
float fLum = ( colInput.r + colInput.g + colInput.b ) / 3;
colMood = lerp(0, colMood, saturate(fLum * 2.0));
colMood = lerp(colMood, 1, saturate(fLum - 0.5) * 2.0);
float4 colOutput = lerp(colInput, colMood, saturate(fLum * fRatio));
color.rgb=max(0, colOutput);
#endif
#ifdef HDR
color.xyz = max(0, color.xyz - Defog * FogColor.xyz);
color.xyz *= pow(2.0f, Exposure);
color.xyz = pow(color.xyz, Gamma);
float3 trollface = color.xyz * float3(1.05f, 0.97f, 1.27f);
color.xyz = lerp(color.xyz, trollface, BlueShift);
#endif
#ifdef FILMICPASS
color = FilmPass(color);
#endif
#ifdef VIBRANCEPASS
float3 lumCoeff = float3(0.2126, 0.7152, 0.0722);
float vibranceluma = dot(lumCoeff, color.xyz);
#ifdef COLORWASHOUT
float colorGray=dot(color.xyz, 0.333);
float
colorGray2=(colorGray*(6.2*colorGray+0.5))/(colorGray*(6.2*colorGray+1.7)+0.06);
float colorGray3=pow(colorGray, 0.36);
float colorWashout=saturate(colorGray2 - ColorWashoutThreshold)/(1.00 -
ColorWashoutThreshold);
colorWashout=saturate(pow(colorWashout, ColorWashoutPow) * ColorWashoutAmount);
float3 middleColor=(color.xyz+0.0001)/(colorGray+0.000001);
middleColor.xyz=lerp(pow(middleColor.xyz, ColorSaturation), middleColor.xyz,
ColorSaturation);
middleColor.xyz=lerp(middleColor.xyz, 1.00,
saturate(colorWashout*ColorWashoutAmount));
float tonemapMix=(0.5 - ColorDullnessAmount)*0.60; //temp
colorGray=lerp(colorGray2, colorGray3, tonemapMix);
color.xyz=middleColor.xyz*colorGray;
color.xyz *= ExpAdjustment;
#endif
#ifdef BORISVIGNETTE
float2 uv=(i.txcoord-0.5)*EVignetteRadius;
float vignetteold=saturate(dot(uv.xy, uv.xy));
vignetteold=pow(vignetteold, EVignetteCurve);
#ifdef VIGNCOLORING
float3 EVignetteColor=float3(VIGNREDAMOUNT, VIGNGREENAMOUNT,
VIGNBLUEAMOUNT);
#else
float3 EVignetteColor=float3(0.0, 0.0, 0.0);
#endif
color.xyz=lerp(color.xyz, EVignetteColor, vignetteold*EVignetteAmount);
#endif
#ifdef HD6_VIGNETTE
#ifdef LEFTANDRIGHT
float3 topv = min((inTex.x+0.5)*2,1.5) * 2; // top
float3 botv = min(((0-inTex.x)+0.5)*2,1.5) * 2; // botton
topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
vigtex.xyz = (topv)*(botv);
#endif
#ifdef TOPANDBOTTOM
float3 topv = min((inTex.y+0.5)*2,1.5) * 2; // top
float3 botv = min(((0-inTex.y)+0.5)*2,1.5) * 2; // botton
topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
vigtex.xyz = (topv)*(botv);
#endif
#ifdef CORNERDARKEN
float3 rightv = min((inTex.x+0.5)*2,1.5) * 2;
float3 leftv = min(((0-inTex.x)+0.5)*2,1.5) * 2;
float3 topv = min((inTex.y+0.5)*2,1.5) * 2;
float3 botv = min(((0-inTex.y)+0.5)*2,1.5) * 2;
rightv= lerp(float3(1,1,1), rightv, sqvigpwr.y);
leftv= lerp(float3(1,1,1), leftv, sqvigpwr.x);
topv= lerp(float3(1,1,1), topv, sqvigpwr.x);
botv= lerp(float3(1,1,1), botv, sqvigpwr.y);
vigtex.xyz = (topv)*(botv)*(rightv)*(leftv);
#endif
#ifdef TVLEVELS
color.xyz = (color.xyz - const_1) * const_2;
#endif
#ifdef USE_DITHER2
float dither_size = 2.0; //move to settings?
float dither_bit = 8.0; //move to settings?
float grid_position = frac(dot(i.txcoord,(screen_size / dither_size)) + (0.5 /
dither_size));
float dither_shift = (0.25) * (1.0 / (pow(2,dither_bit) - 1.0));
color.xyz += lerp(2.0 * dither_shift,(-2.0 * dither_shift),grid_position);
#endif
#ifdef USE_DITHER
float dither_size = 2.0; //move to settings?
float dither_bit = 8.0; //move to settings?
float grid_position = frac(dot(i.txcoord,(screen_size / dither_size)) + (0.5 /
dither_size));
float dither_shift = (0.25) * (1.0 / (pow(2,dither_bit) - 1.0));
float3 dither_shift_RGB = float3(dither_shift, dither_shift, dither_shift);
color.xyz += lerp(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);
#endif
#define px BUFFER_RCP_WIDTH
#define py BUFFER_RCP_HEIGHT
#define pixel float2(px,py)
#ifdef BORDER
float2 distancefromcenter = abs(i.txcoord.xy - 0.5);
bool2 screen_border = step(0.5 - pixel,distancefromcenter);
color.xyz = (!dot(screen_border, 1.0)) ? color.xyz : 0.0;
#endif
color.w = 1.0;
return color*sharpencolor;
}
#ifdef LIGHTSCATTERING
float4 PS_ProcessSunShafts(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float2 texCoord = IN.txcoord;
// Calculate vector from pixel to light source in screen space.
half2 deltaTexCoord = (texCoord - ScreenLightPos.xy);
// Divide by number of samples and scale by control factor.
deltaTexCoord *= 1.0f / NUM_SAMPLES * Density;
// Store initial sample.
half3 color = max(float4(0,0,0,0),tex2D(InputSampler, texCoord)-SStresh);
// Set up illumination decay factor.
half illuminationDecay = 1.0f;
// Evaluate summation from Equation 3 NUM_SAMPLES iterations.
for (int i = 0; i < NUM_SAMPLES; i++)
{
// Step sample location along ray.
texCoord -= deltaTexCoord;
// Retrieve sample at new location.
half3 sample = max(float4(0,0,0,0),tex2D(InputSampler, texCoord)-
SStresh);
// Apply sample attenuation scale/decay factors.
#ifdef TINTCOLOR
sample.r *= REDAMOUNT;
sample.g *= GREENAMOUNT;
sample.b *= BLUEAMOUNT;
#endif
#ifdef COLORING
sample = dot(sample, float3(0.3, 0.59, 0.11));
sample.r *= REDAMOUNT;
sample.g *= GREENAMOUNT;
sample.b *= BLUEAMOUNT;
#endif
#ifdef ANAMORPHICFLARE
float4 CCShadow (VS_OUTPUT_POST i, float2 vPos : VPOS) : COLOR
{
#ifdef FLAREMODE_1
sum += tex2Dlod(InputSampler, float4(i.txcoord.y - 4.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.05;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y - 3.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.09;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y - 2.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.12;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y - fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.15;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y,
i.txcoord.y,0,fBlurDownsampling)) * 0.16;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y + fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.15;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y + 2.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.12;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y + 3.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.09;
sum += tex2Dlod(InputSampler, float4(i.txcoord.y + 4.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.05;
#endif
#ifdef FLAREMODE_2
sum += tex2Dlod(InputSampler, float4(i.txcoord.x - 100.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.01;
sum += tex2Dlod(InputSampler, float4(i.txcoord.x - 99.0*fBlurSize,
i.txcoord.y,0,fBlurDownsampling)) * 0.01;
#endif
#ifdef FORCECOLOR
sum = dot(sum, float3(0.3, 0.59, 0.11));
#endif
#ifdef ANAMORPHICTINTCOLOR
sum.r = sum.r * ANAMORPHICREDAMOUNT;
sum.g = sum.g * ANAMORPHICGREENAMOUNT;
sum.b = sum.b * ANAMORPHICBLUEAMOUNT;
#endif
float4 Color;
midtones.w = midtones.x;
midtones.x = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.x += midtones.w;
midtones.w = midtones.y;
midtones.y = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.y += midtones.w;
midtones.w = midtones.z;
midtones.z = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.z += midtones.w;
}
highlights.w = highlights.x;
highlights.x = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.x += highlights.w;
highlights.w = highlights.y;
highlights.y = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.y += highlights.w;
highlights.w = highlights.z;
highlights.z = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.z += highlights.w;
}
}
#endif
#ifdef COLORMODBLOOM
bloomsample += tex2Dlod(InputSampler, float4(i.txcoord.x,
i.txcoord.y,0,BloomDownsampling)) * 0.19741;
#endif
#ifndef COLORBLOOM
bloomsample = dot(bloomsample, float3(0.3, 0.59, 0.11));
#endif
bloomsample =max(1.0,0.0);
float4 Color;
Color = smpl;
return Color;
}
#ifdef DOF
float4 PS_ProcessDoFBokeh(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float depth = linearize(tex2D(SamplerDepth,IN.txcoord.xy).x);
if (autofocus)
{
fDepth = linearize(tex2D(SamplerDepth,focus).x);
}
float blur = 0.0;
if (manualdof)
{
float a = depth-fDepth; //focal plane
float b = (a-fdofstart)/fdofdist; //far DoF
float c = (-a-ndofstart)/ndofdist; //near Dof
blur = (a>0.0)?b:c;
}
else
{
float f = focalLength; //focal length in mm
float d = fDepth*1000.0; //focal plane in mm
float o = depth*1000.0; //depth in mm
float a = (o*f)/(o-f);
float b = (d*f)/(d-f);
float c = (d-f)/(d*fstop*CoC);
blur = abs(a-b)*c;
}
blur = saturate(blur);
float2 noise = rand(IN.txcoord.xy)*namount*blur;
float w = (1.0/screenRes.x)*blur*maxblur+noise.x;
float h = (1.0/screenRes.y)*blur*maxblur+noise.y;
s += 1.0*lerp(1.0,i/rings,bias)*p;
}
}
col = col/s; //divide by sample count
}
if (vignetting)
{
col *= vignette(IN.txcoord.xy);
}
#ifdef BORDER_DOF
float2 distancefromcenter = abs(IN.txcoord.xy - 0.5);
bool2 screen_border = step(0.5 - pixel,distancefromcenter);
#ifdef CHROMATICABBERATION
float4 PS_PostProcessChroma(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 coord=0.0;
coord.xy=IN.txcoord.xy;
coord.w=0.0;
float3 eta =
float3(1.0+ChromaticAmount*0.9,1.0+ChromaticAmount*0.6,1.0+ChromaticAmount*0.3);
float2 center;
center.x = coord.x-0.5;
center.y = coord.y-0.5;
float LensZoom = 1.0/LensSize;
float x = f*LensZoom*(coord.x-0.5)+0.5;
float y = f*LensZoom*(coord.y-0.5)+0.5;
float2 rCoords = (f*eta.r)*LensZoom*(center.xy*0.5)+0.5;
float2 gCoords = (f*eta.g)*LensZoom*(center.xy*0.5)+0.5;
float2 bCoords = (f*eta.b)*LensZoom*(center.xy*0.5)+0.5;
float4 rgbyM;
rgbyM.xyz = FxaaTexTop(InputSampler, pos.xy).xyz;
rgbyM.w = dot(rgbyM.xyz, float3(0.299, 0.587, 0.114));
float lumaE = dot(FxaaTexOff(InputSampler, pos.xy, float2( 1, 0), rcpFrame.xy).xyz,
float3(0.299, 0.587, 0.114));
float lumaS = dot(FxaaTexOff(InputSampler, pos.xy, float2( 0, 1), rcpFrame.xy).xyz,
float3(0.299, 0.587, 0.114));
float lumaM = rgbyM.w;
gradientN *= FXAA_SEARCH_THRESHOLD;
#if (FXAA_LINEAR == 1)
lumaL *= lumaL;
#endif
float lumaF = dot(rgbF, float3(0.299, 0.587, 0.114)) + (1.0/(65536.0*256.0));
float lumaB = lerp(lumaF, lumaL, blendL);
float scale = min(4.0, lumaB/lumaF);
rgbF *= scale;
#ifdef NOISE
float4 PS_ProcessPass_ImageGrain(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
float4 res;
float2 coord = IN.txcoord.xy;
res.xyz = tex2D(InputSampler, coord.xy).xyz;
res.xyz += tex2D(SamplerNoise, coord.xy * 1024).xyz * Grain(float3(coord.xy,
SEED));
res.a = 1.0;
return res;
}
#endif
#ifdef MATSO_FLARE
float3 BrightPass(float2 tex)
{
float3 couleur = tex2D(InputSampler, tex).rgb;
float3 bC = max(couleur - float3(fFlareLuminance, fFlareLuminance,
fFlareLuminance), 0.0);
float bright = dot(bC, 1.0);
bright = smoothstep(0.0f, 0.5, bright);
return lerp(0.0, couleur, bright);
}
#ifdef fFlareHorizontal
#define fFlareAxis 0
#endif
#ifdef fFlareVertical
#define fFlareAxis 90
#endif
technique PostProcess2
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 FxaaPixelShader();
FogEnable=FALSE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
#ifdef CHROMATICABBERATION
pass P1
{
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
#endif
}
technique PostProcess3
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 FxaaPixelShader();
FogEnable=FALSE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
technique PostProcess4
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 FxaaPixelShader();
FogEnable=FALSE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}
technique PostProcess5
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 FxaaPixelShader();
FogEnable=FALSE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
#ifdef NOISE
pass P1
{
DitherEnable=FALSE;
ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
StencilEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
#endif
}
technique PostProcess6
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 CBloom();
}
}
#ifdef ANAMORPHICFLARE
technique PostProcess7
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 CCShadow();
}
}
#endif
#ifdef DOF
#ifdef ANAMORPHICFLARE
technique PostProcess8
#else
technique PostProcess7
#endif
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 PS_ProcessDoFBokeh();
CullMode=NONE;
}
}
#endif