| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918 |
- /**
- * SHADER ADDON
- * Featuring BlurShift, Sharpen, Noise, LumaSharpen, Vibrance, Contrast, Black Level
- * Exterior/Interior separation ready (some also has Day/Night factors), GUI-enabled
- * By ZeroKing
- */
- /**
- * ENBSeries
- * visit http://enbdev.com for updates
- * Copyright (c) 2007-2014 Boris Vorontsov
- */
-
- //--------------------------//
- // Internal parameters //
- // Can be modified //
- //--------------------------//
- //////////////////
- // DEFINES //
- //////////////////
- #define ESHARPENING
- #define ESHARPENINGCOLOR
- #define ECOLORSHIFT
- #define SharpMethod 4
- #define NoiseMethod 0
- // Set your resolution here
- float XCoord <
- string UIName="Horizontal Pixel Resolution";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=7680.0;
- > = {1920};
- float YCoord <
- string UIName="Vertical Pixel Resolution";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=4320.0;
- > = {1080};
- ///////////////
- // CHOICES //
- ///////////////
- bool C_BLACKLEVEL <
- string UIName = "Enable Black Level";
- > = {false};
- bool C_CONTRASTCURVES <
- string UIName = "Enable Contrast";
- > = {false};
- bool C_VIBRANCE <
- string UIName = "Enable Vibrance";
- > = {false};
-
- //////////////////////////////
- // BLUR-SHIFT AND SHARPEN //
- //////////////////////////////
- #define BlurSamplingRange BlurRange
- #define SharpSamplingRange SharpRange
- #define SharpeningAmount SharpAmount
- #define ShiftSamplingRange ShiftRange
- float BlurRange <
- string UIName="Blur Sampling Range";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.25};
- float SharpRange <
- string UIName="Sharp Sampling Range";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.75};
- float SharpAmount <
- string UIName="Sharpening Amount";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=5.0;
- > = {1.5};
-
- float ShiftRange <
- string UIName="Shift Sampling Range";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.25};
-
- //////////////
- // NOISE //
- //////////////
- float NoiseAmountExt <
- string UIName="Noise Amount - Exterior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.0};
- float NoiseAmountInt <
- string UIName="Noise Amount - Interior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.0};
- float NoiseFinenessExt <
- string UIName="Noise Fineness - Exterior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=100.0;
- > = {50};
- float NoiseFinenessInt <
- string UIName="Noise Fineness - Interior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=100.0;
- > = {50};
- //////////////////
- // CONTRAST //
- //////////////////
- float ContrastCurveDayExt <
- string UIName="Contrast - Exterior Day";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float ContrastCurveDayInt <
- string UIName="Contrast - Interior Day";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float ContrastCurveNightExt <
- string UIName="Contrast - Exterior Night";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float ContrastCurveNightInt <
- string UIName="Contrast - Interior Night";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- //////////////////
- // VIBRANCE //
- //////////////////
- float VibranceDayExt <
- string UIName="Vibrance - Exterior Day";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float VibranceDayInt <
- string UIName="Vibrance - Interior Day";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float VibranceNightExt <
- string UIName="Vibrance - Exterior Night";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
- float VibranceNightInt <
- string UIName="Vibrance - Interior Night";
- string UIWidget="Spinner";
- float UIMin=-1.0;
- float UIMax=1.0;
- > = {0};
-
- ////////////////////
- // LUMASHARPEN //
- ////////////////////
- float sharp_strengthExt <
- string UIName="LumaSharpen Strength - Exterior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=5.0;
- > = {0.75};
- float sharp_strengthInt <
- string UIName="LumaSharpen Strength - Interior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=5.0;
- > = {0.75};
- float sharp_clampExt <
- string UIName="LumaSharpen Clamp - Exterior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.025};
- float sharp_clampInt <
- string UIName="LumaSharpen Clamp - Interior";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=1.0;
- > = {0.025};
- ////////////////////
- // BLACK LEVELS //
- ////////////////////
- float BlackPointDayExt <
- string UIName="Black Level - Exterior Day";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {5};
- float BlackPointDayInt <
- string UIName="Black Level - Interior Day";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {5};
- float WhitePointDayExt <
- string UIName="White Level - Exterior Day";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {235};
- float WhitePointDayInt <
- string UIName="White Level - Interior Day";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {235};
- float BlackPointNightExt <
- string UIName="Black Level - Exterior Night";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {5};
- float BlackPointNightInt <
- string UIName="Black Level - Interior Night";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {5};
- float WhitePointNightExt <
- string UIName="White Level - Exterior Night";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {235};
- float WhitePointNightInt <
- string UIName="White Level - Interior Night";
- string UIWidget="Spinner";
- float UIMin=0.0;
- float UIMax=255.0;
- > = {235};
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- //--------------------------//
- // External parameters //
- // Do not modify //
- //--------------------------//
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // 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
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////
- // TEXTURES //
- //////////////////
- texture2D texColor;
- texture2D texNoise;
- ///////////////////
- // SAMPLERS //
- ///////////////////
- sampler2D SamplerColor = sampler_state
- {
- Texture = <texColor>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerNoise = sampler_state
- {
- Texture = <texNoise>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE;
- AddressU = Wrap;
- AddressV = Wrap;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- //////////////////
- // STRUCTS //
- //////////////////
- struct VS_OUTPUT_POST
- {
- float4 vpos : POSITION;
- float2 txcoord : TEXCOORD0;
- };
- struct VS_INPUT_POST
- {
- float3 pos : POSITION;
- float2 txcoord : TEXCOORD0;
- };
- VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
- {
- VS_OUTPUT_POST OUT;
- 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;
- }
- //////////////////
- // SHADERS //
- //////////////////
- float4 PS_ProcessLumaSharpen(VS_OUTPUT_POST IN, float2 vPos : VPOS, float2 tex : TEXCOORD0) : COLOR
- {
- float2 coord = IN.txcoord.xy;
-
- #define px (1/XCoord)
- #define py (1/YCoord)
-
- // Bias value
- float offset_bias = 1.0;
-
- float sharp_strength = sharp_strengthExt;
- float sharp_clamp = sharp_clampExt;
- if (EInteriorFactor)
- {
- sharp_strength = sharp_strengthInt;
- sharp_clamp = sharp_clampInt;
- };
-
- #define sharp_strength_luma (CoefLuma * sharp_strength)
- #define CoefLuma float4(0.2126, 0.7152, 0.0722, 0)
-
- half4 ori = tex2D(SamplerColor, coord.xy);
-
- [branch] if (any(frac(ori.rgb)))
- {
- #if SharpMethod == 1
- // -- Gaussian filter --
- // [ 2/9, 4/9, ] [ 1 , 2 , ]
- // [ 4/9, 8/9, 4/9] = [ 2 , 4 , 2 ]
- // [ , 2/9, 2/9] [ , 2 , 1 ]
-
- half4 blur_ori = tex2Dlod(SamplerColor, float4(tex,tex) + float4(-px,py,-px,py) / 3 * offset_bias); // North West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(px,-py,px,-py) / 3 * offset_bias); // South East
-
- //Divide by the number of texture fetches
- blur_ori /= 2;
- #endif
-
- // -- Pattern 2 -- A 9 tap gaussian using 4+1 texture fetches.
- #if SharpMethod == 2
- // -- Gaussian filter --
- // [ .25, .50, .25] [ 1 , 2 , 1 ]
- // [ .50, 1, .50] = [ 2 , 4 , 2 ]
- // [ .25, .50, .25] [ 1 , 2 , 1 ]
-
- half4 blur_ori = tex2Dlod(SamplerColor, float4(tex,tex) + float4(-px,py,-px,py) * 0.5 * offset_bias); // North West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(px,-py,px,-py) * 0.5 * offset_bias); // South East
-
- if (any((blur_ori.rgb / 2) - ori.rgb))
- {
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(-px,-py,-px,-py) * 0.5 * offset_bias); // South West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(px,py,px,py) * 0.5 * offset_bias); // North East
-
- //Divide by the number of texture fetches
- blur_ori *= 0.25;;
- }
-
- //Divide by the number of texture fetches
- blur_ori *= 0.25;;
- #endif
-
- // -- Pattern 3 -- An experimental 17 tap gaussian using 4+1 texture fetches.
- #if SharpMethod == 3
- // -- Gaussian filter --
- // [ , 4 , 6 , , ]
- // [ ,16 ,24 ,16 , 4 ]
- // [ 6 ,24 ,50 ,24 , 6 ]
- // [ 4 ,16 ,24 ,16 , ]
- // [ , , 6 , 4 , ]
-
- half4 blur_ori = tex2Dlod(SamplerColor, float4(tex,tex) + float4(-0.4*px,1.2*py,-0.4*px,1.2*py) * offset_bias); // North North West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(0.4*px,-1.2*py,0.4*px,-1.2*py) * offset_bias); // South South East
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(1.2*px,0.4*py,0,0) * offset_bias); // East North East
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(-1.2*px,-0.4*py,0,0) * offset_bias); // West South West
- blur_ori += ori; // Probably not needed. Only serves to lessen the effect.
-
- blur_ori /= 5; //Divide by the number of texture fetches
- #endif
-
- // -- Pattern 4 -- A 9 tap high pass using 4+1 texture fetches.
- #if SharpMethod == 4
- // -- Gaussian filter --
- // [ .50, .50, .50] [ 1 , 1 , 1 ]
- // [ .50, , .50] = [ 1 , , 1 ]
- // [ .50, .50, .50] [ 1 , 1 , 1 ]
-
- half4 blur_ori = tex2Dlod(SamplerColor, float4(tex,tex) + float4(0.5 * -px,py,0.5 * -px,py) * offset_bias); // North North West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(0.5 * px,-py,0.5 * px,-py)); // South South East
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(-px,0.5 * -py,-px,0.5 * -py)); // West South West
- blur_ori += tex2Dlod(SamplerColor, float4(tex,tex) + float4(px,0.5 * py,px,0.5 * py) * offset_bias); // East North East
- blur_ori += (2 * ori); // Probably not needed. Only serves to lessen the effect.
-
- blur_ori /= 6; //Divide by the number of texture fetches
- #endif
-
- // -- Calculate the sharpening --
- half sharp = ori - blur_ori;
- // -- Adjust strength of the sharpening --
- sharp = dot(sharp, sharp_strength_luma);
- // -- Clamping the maximum amount of sharpening to prevent halo artifacts --
- sharp = clamp(sharp, -sharp_clamp, sharp_clamp);
- // -- Combining the values to get the final sharpened pixel --
- half4 done = ori + sharp;
- return done;
- }
-
- else
- {
- return ori;
- }
- }
- float4 PS_ProcessBlur(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float4 res;
- float4 coord=0.0;
- coord.xy=IN.txcoord.xy;
- float4 origcolor;
- coord.w=0.0;
- origcolor=tex2Dlod(SamplerColor, coord);
- float2 offset[16]=
- {
- float2(1.0, 1.0),
- float2(-1.0, -1.0),
- float2(-1.0, 1.0),
- float2(1.0, -1.0),
- float2(1.0, 0.0),
- float2(-1.0, 0.0),
- float2(0.0, 1.0),
- float2(0.0, -1.0),
- float2(1.41, 0.0),
- float2(-1.41, 0.0),
- float2(0.0, 1.41),
- float2(0.0, -1.41),
- float2(1.41, 1.41),
- float2(-1.41, -1.41),
- float2(-1.41, 1.41),
- float2(1.41, -1.41)
- };
- int i=0;
- float4 tcol=origcolor;
- float invscreensize=1.0/ScreenSize;
- for (i=0; i<16; i++)
- {
- float2 tdir=offset[i].xy;
- coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*BlurSamplingRange;
- float4 ct=tex2Dlod(SamplerColor, coord);
- tcol+=ct;
- }
- tcol*=0.05882353;
- res.xyz=tcol.xyz;
-
- res.w=1.0;
- return res;
- }
- float4 PS_ProcessSharpen(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float4 res;
- float4 coord=0.0;
- coord.xy=IN.txcoord.xy;
- float4 origcolor;
- coord.w=0.0;
- origcolor=tex2Dlod(SamplerColor, coord);
- float2 offset[8]=
- {
- float2(1.0, 1.0),
- float2(-1.0, -1.0),
- float2(-1.0, 1.0),
- float2(1.0, -1.0),
- float2(1.41, 0.0),
- float2(-1.41, 0.0),
- float2(0.0, 1.41),
- float2(0.0, -1.41)
- };
- int i=0;
- float4 tcol=origcolor;
- float invscreensize=1.0/ScreenSize;
-
- for (i=0; i<8; i++)
- {
- float2 tdir=offset[i].xy;
- coord.xy=IN.txcoord.xy+tdir.xy*invscreensize*SharpSamplingRange;
- float4 ct=tex2Dlod(SamplerColor, coord);
- tcol+=ct;
- }
- tcol*=0.1111;
- //sharp
- #ifdef ESHARPENING
- #ifdef ESHARPENINGCOLOR
- //color
- res=origcolor*(1.0+((origcolor-tcol)*SharpeningAmount));
- #else
- //non color
- float difffact=dot((origcolor.xyz-tcol.xyz), 0.333);
- res=origcolor*(1.0+difffact*SharpeningAmount);
- #endif
- //less sharpening for bright pixels
- float rgray=origcolor.z;
- rgray=pow(rgray, 3.0);
- res=lerp(res, origcolor, saturate(rgray));
- #endif
- res.w=1.0;
- return res;
- }
- float4 PS_ProcessShift(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float4 res;
- float4 coord=0.0;
- coord.xy=IN.txcoord.xy;
- float4 origcolor;
- coord.w=0.0;
- origcolor=tex2Dlod(SamplerColor, coord);
- int i=0;
- #ifdef ECOLORSHIFT
- float4 tcol=origcolor;
- float2 invscreensize=1.0/ScreenSize.x;
- invscreensize.y=invscreensize.y/ScreenSize.z;
- coord.xy=IN.txcoord.xy;
- origcolor=tex2Dlod(SamplerColor, coord);
- res.y=origcolor.y;
- coord.xy=IN.txcoord.xy;
- coord.y-=invscreensize*ShiftSamplingRange;
- origcolor=tex2Dlod(SamplerColor, coord);
- res.x=origcolor.x;
- coord.xy=IN.txcoord.xy;
- coord.y+=invscreensize*ShiftSamplingRange;
- origcolor=tex2Dlod(SamplerColor, coord);
- res.z=origcolor.z;
- #endif
- res.w=1.0;
- return res;
- }
- float4 PS_ProcessContrast(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float ContrastCurve = lerp(ContrastCurveNightExt, ContrastCurveDayExt, ENightDayFactor);
- if (EInteriorFactor)
- {
- ContrastCurve = lerp(ContrastCurveNightInt, ContrastCurveDayInt, ENightDayFactor);
- };
-
- float4 res;
- float3 origcolor=tex2D(SamplerColor, IN.txcoord.xy);
- float3 lumCoeff = float3(0.212656, 0.715158, 0.072186); //Calculate luma with these values
-
- float luma = dot(lumCoeff, origcolor.rgb);
- float3 chroma = origcolor.rgb - luma;
-
- float Curves_contrast_blend = ContrastCurve;
- float PI = 3.1415926535897932384626433832795;
-
- float x = luma; //If the curve should be applied to Luma
-
- x = x - 0.5;
- x = x / ((abs(x)*1.25) + 0.375 ) + 0.5;
-
- x = lerp(luma, x, Curves_contrast_blend); //if the curve should be applied to both Luma and Chroma
-
- if (C_CONTRASTCURVES==true)
- {
- res.rgb = x + chroma; //Blend by Curves_contrast
- }
-
- if (C_CONTRASTCURVES==false)
- {
- res.rgb = origcolor.rgb;
- }
-
- res.w=1.0;
- return res;
- }
- float4 PS_ProcessVibrance(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float Vibrance = lerp(VibranceNightExt, VibranceDayExt, ENightDayFactor);
- if (EInteriorFactor)
- {
- Vibrance = lerp(VibranceNightInt, VibranceDayInt, ENightDayFactor);
- };
-
- float4 res;
- float3 origcolor = tex2D(SamplerColor, IN.txcoord.xy);
- float3 lumCoeff = float3(0.212656, 0.715158, 0.072186); //Calculate luma with these values
-
- float max_color = max(origcolor.r, max(origcolor.g,origcolor.b)); //Find the strongest color
- float min_color = min(origcolor.r, min(origcolor.g,origcolor.b)); //Find the weakest color
- float color_saturation = max_color - min_color; //Saturation is the difference between min and max
- float luma = dot(lumCoeff, origcolor.rgb); //Calculate luma (grey)
- if (C_VIBRANCE==true)
- {
- res.rgb = lerp(luma, origcolor.rgb, (1.0 + (Vibrance * (1.0 - (sign(Vibrance) * color_saturation))))); //Extrapolate between luma and original by 1 + (1-saturation) - current
- }
-
- if (C_VIBRANCE==false)
- {
- res.rgb = origcolor.rgb;
- }
-
- res.w=1.0;
- return res;
- }
- float4 PS_ProcessNoise(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float NoiseAmount = NoiseAmountExt;
- float NoiseFineness = NoiseFinenessExt;
- if (EInteriorFactor)
- {
- NoiseAmount = NoiseAmountInt;
- NoiseFineness = NoiseFinenessInt;
- };
- float4 coord=0.0;
-
- coord.xy=IN.txcoord.xy;
- coord.w=0.0;
-
- #define noise_strength_luma (CoefLuma * NoiseAmount)
- #define CoefLuma float4(0.2126, 0.7152, 0.0722, 0)
-
- float4 tcol=tex2Dlod(SamplerColor, coord);
- float origgray=max(tcol.x, tcol.y);
- origgray=max(origgray, tcol.z);
- coord.xy=IN.txcoord.xy*NoiseFineness + frac(Timer.x * 100000.0 + Timer.x);
- float4 cnoi=tex2Dlod(SamplerNoise, coord);
-
- #if NoiseMethod == 1
- tcol=lerp(tcol, (cnoi.x+0.5)*tcol, noise_strength_luma*saturate(1.0-origgray*0.5));
- #endif
-
- #if NoiseMethod == 0
- tcol=lerp(tcol, (cnoi.x+0.5)*tcol, NoiseAmount*saturate(1.0-origgray*0.5));
- #endif
-
- tcol.w=1.0;
- return tcol;
- }
- float4 PS_LevelsPass(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float Levels_black_point = lerp(BlackPointNightExt, BlackPointDayExt, ENightDayFactor);
- float Levels_white_point = lerp(WhitePointNightExt, WhitePointDayExt, ENightDayFactor);
- if (EInteriorFactor)
- {
- Levels_black_point = lerp(BlackPointNightInt, BlackPointDayInt, ENightDayFactor);
- Levels_white_point = lerp(WhitePointNightInt, WhitePointDayInt, ENightDayFactor);
- };
- #define black_point_float ( Levels_black_point / 255.0 )
- #define white_point_float ( 255.0 / (Levels_white_point - Levels_black_point))
-
- float4 res;
- float3 origcolor = tex2D(SamplerColor, IN.txcoord.xy);
-
- if (C_BLACKLEVEL==true)
- {
- res.rgb = origcolor.rgb * white_point_float - (black_point_float * white_point_float);
- }
-
- if (C_BLACKLEVEL==false)
- {
- res.rgb = origcolor.rgb;
- }
-
- res.w=1.0;
- return res;
- }
- ///////////////////////
- // TECHNIQUES //
- ///////////////////////
- technique PostProcess
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessNoise();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess2
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessBlur();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess3
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessSharpen();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess4
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessShift();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess5
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessContrast();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess6
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessVibrance();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique PostProcess7
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessLumaSharpen();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
-
- technique PostProcess8
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_LevelsPass();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
|