| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848 |
- //++++++++++++++++++++++++++++++++++++++++++++
- // ENBSeries effect file
- // visit http://enbdev.com for updates
- // Copyright (c) 2007-2011 Boris Vorontsov
- //
- // Using decompiled shader of TES Skyrim
- //++++++++++++++++++++++++++++++++++++++++++++
- //+++++++++++++++++++++++++++++++++++++++++++++++
- // Unreal Cinema ENB - The Directors Cut - 0.219
- //+++++++++++++++++++++++++++++++++++++++++++++++
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // Additions and Tweaking by Kyokushinoyama, & Unreal Warfare
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- #define ENABLE_FLIP_DAY_NIGHT_FACTOR
- //++++++++++++++++++++++++++++++++++++++++++++
- //#define NOT_BLURRING_SKY_MODE
- #define DEPTH_OF_FIELD_QUALITY 2
- //1-7
- //++++++++++++++++++++++++++++++++++++++++++++
- //#define USE_TIGHT_OFFSETS 1
- //#define USE_CENTERED_OFFSETS 1
- //#define USE_REGULAR_OFFSETS 1
- //#define USE_ORIGINAL_OFFSETS 1
- //#define USE_WIDE_OFFSETS 1
- #define USE_NATURAL_OFFSETS 1
- //++++++++++++++++++++++++++++++++++++++++++++
- #define AUTO_FOCUS
- //++++++++++++++++++++++++++++++++++++++++++++
- //#define TILT_SHIFT
- // Day, Night, Interior angles
- float TiltShiftAngleDay=30.0;
- float TiltShiftAngleNight=30.0;
- float TiltShiftAngleInterior=30.0;
- //++++++++++++++++++++++++++++++++++++++++++++
- #define POLYGONAL_BOKEH
- #define POLYGON_NUM 5
- //#define POLYGON_NUM 6
- //#define POLYGON_NUM 7
- //#define POLYGON_NUM 8
- //++++++++++++++++++++++++++++++++++++++++++++
- // FOCUS POINT DAY
- float2 FocusPointDay=float2(0.5, 0.5);
- // FOCUS POINT NIGHT
- float2 FocusPointNight=float2(0.5, 0.5);
- // FOCUS POINT INTERIOR
- float2 FocusPointInterior=float2(0.5, 0.5);
- // DYNAMIC DOF DAY SETTINGS
- float FocusSampleRangeDay=1.0;
- float NearBlurCurveDay=14.70;
- float FarBlurCurveDay=2.75;
- float DepthClipDay=999999999.0;
- // DYNAMIC DOF NIGHT SETTINGS
- float FocusSampleRangeNight=1.0;
- float NearBlurCurveNight=14.70;
- float FarBlurCurveNight=2.75;
- float DepthClipNight=999999999.0;
- // DYNAMIC DOF INTERIOR SETTINGS
- float FocusSampleRangeInterior=1.0;
- float NearBlurCurveInterior=14.70;
- float FarBlurCurveInterior=2.75;
- float DepthClipInterior=999999999.0;
- //++++++++++++++++++++++++++++++++++++++++++++
- // DAY SETTINGS
- float FocalPlaneDepthDay=1.00;
- float FarBlurDepthDay=100.00;
- // NIGHT SETTINGS
- float FocalPlaneDepthNight=1.00;
- float FarBlurDepthNight=100.00;
- // INTERIOR SETTINGS
- float FocalPlaneDepthInterior=1.00;
- float FarBlurDepthInterior=100.00;
- //++++++++++++++++++++++++++++++++++++++++++++
- // BOKEH DAY SETTINGS
- float BokehBiasDay=0.00; //Impacts overall brightness-exposure - Leave @0.00 for normalize
- float BokehBiasCurveDay=0.75;
- float BokehBrightnessThresholdDay=1.00;
- float BokehBrightnessMultiplierDay=1.00;
- float RadiusScaleMultiplierDay=0.13;
- // BOKEH NIGHT SETTINGS
- float BokehBiasNight=0.00; //Impacts overall brightness-exposure - Leave @0.00 for normalize
- float BokehBiasCurveNight=0.75;
- float BokehBrightnessThresholdNight=1.00;
- float BokehBrightnessMultiplierNight=1.00;
- float RadiusScaleMultiplierNight=0.13;
- // BOKEH INTERIOR SETTINGS
- float BokehBiasInterior=0.00; //Impacts overall brightness-exposure - Leave @0.00 for normalize
- float BokehBiasCurveInterior=0.75;
- float BokehBrightnessThresholdInterior=1.00;
- float BokehBrightnessMultiplierInterior=1.00;
- float RadiusScaleMultiplierInterior=0.13;
- //++++++++++++++++++++++++++++++++++++++++++++
- // GRAIN GLOBAL SETTINGS
- float NoiseAmount=0.055;
- float NoiseCurve=0.0;
- // GRAIN DIFFUSION DAY
- float NoiseDiffusionDay=3.0; //High values dampen grain, depending on Noise Amounts and Curves - 3.0 will 'disable' grain
- // GRAIN DIFFUSION NIGHT
- float NoiseDiffusionNight=3.0; //High values dampen grain, depending on Noise Amounts and Curves - 3.0 will 'disable' grain
- // GRAIN DIFFUSION INTERIOR
- float NoiseDiffusionInterior=3.0; //High values dampen grain, depending on Noise Amounts and Curves - 3.0 will 'disable' grain
- //++++++++++++++++++++++++++++++++++++++++++++
- // CHROMATIC ABERRATION DAY
- float ChromaticAberrationAmountDay=0.25;
- // CHROMATIC ABERRATION NIGHT
- float ChromaticAberrationAmountNight=0.25;
- // CHROMATIC ABERRATION INTERIOR
- float ChromaticAberrationAmountInterior=0.25;
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // EXTERNAL PARAMETERS BEGINS HERE, SHOULD NOT BE MODIFIED UNLESS YOU KNOW WHAT YOU ARE DOING!!!
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- #ifndef ENABLE_FLIP_DAY_NIGHT_FACTOR
- 1 - ENightDayFactor = ENightDayFactor;
- #endif
- //++++++++++++++++++++++++++++++++++++++++++++
- float4 tempF1; //0,1,2,3
- float4 tempF2; //5,6,7,8
- float4 tempF3; //9,0
- float4 ScreenSize;
- float4 Timer;
- float ENightDayFactor;
- float EInteriorFactor;
- float FadeFactor;
- texture2D texColor;
- texture2D texDepth;
- texture2D texNoise;
- texture2D texPalette;
- texture2D texFocus; //computed focusing depth
- texture2D texCurr; //4*4 texture for focusing
- texture2D texPrev; //4*4 texture for focusing
- sampler2D SamplerColor = sampler_state
- {
- Texture = <texColor>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE; //LINEAR
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0; //9 //[KYO : TO DO : experiment with mipmaps]
- MipMapLodBias=0;
- };
- sampler2D SamplerDepth = sampler_state
- {
- Texture = <texDepth>;
- MinFilter = POINT;
- MagFilter = POINT;
- MipFilter = NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerNoise = sampler_state
- {
- Texture = <texNoise>;
- MinFilter = POINT;
- MagFilter = POINT;
- MipFilter = NONE;//NONE;
- AddressU = Wrap;
- AddressV = Wrap;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerPalette = sampler_state
- {
- Texture = <texPalette>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE;//NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerCurr = sampler_state
- {
- Texture = <texCurr>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = LINEAR;//NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerPrev = sampler_state
- {
- Texture = <texPrev>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- sampler2D SamplerFocus = sampler_state
- {
- Texture = <texFocus>;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = NONE;
- AddressU = Clamp;
- AddressV = Clamp;
- SRGBTexture=FALSE;
- MaxMipLevel=0;
- MipMapLodBias=0;
- };
- struct VS_OUTPUT_POST
- {
- float4 vpos : POSITION;
- float2 txcoord : TEXCOORD0;
- };
- struct VS_INPUT_POST
- {
- float3 pos : POSITION;
- float2 txcoord : TEXCOORD0;
- };
-
- //++++++++++++++++++++++++++++++++++++++++++++
- VS_OUTPUT_POST VS_Focus(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;
- }
- float linearlizeDepth(float nonlinearDepth)
- {
- float2 dofProj=float2(0.0509804, 3098.0392);
- float2 dofDist=float2(0.0, 0.0509804);
-
- float4 depth=nonlinearDepth;
-
-
- depth.y=-dofProj.x + dofProj.y;
- depth.y=1.0/depth.y;
- depth.z=depth.y * dofProj.y;
- depth.z=depth.z * -dofProj.x;
- depth.x=dofProj.y * -depth.y + depth.x;
- depth.x=1.0/depth.x;
- depth.y=depth.z * depth.x;
- depth.x=depth.z * depth.x - dofDist.y;
- depth.x+=dofDist.x * -0.5;
- depth.x=max(depth.x, 0.0);
-
- return depth.x;
- }
- float4 PS_ReadFocus(VS_OUTPUT_POST IN) : COLOR
- {
- //++++++++++++++++++++++++++++++++++++++++++++
- float FocusPoint =lerp( lerp( FocusPointDay, FocusPointNight, 1 - ENightDayFactor ), FocusPointInterior, EInteriorFactor);
- float2 uvsrc=FocusPoint;
- float2 pixelSize=ScreenSize.y;
- pixelSize.y*=ScreenSize.z;
- #ifdef USE_TIGHT_OFFSETS
- const float2 offset[4] =
- {
- float2(0.262, 0.641),
- float2(0.262, -0.641),
- float2(0.641, 0.262),
- float2(-0.641, 0.262)
- };
- #endif
- #ifdef USE_CENTERED_OFFSETS
- const float2 offset[4] =
- {
- float2(0.5, 1.0),
- float2(0.5, -1.0),
- float2(1.0, 0.5),
- float2(-1.0, 0.5)
- };
- #endif
- #ifdef USE_REGULAR_OFFSETS
- const float2 offset[4] =
- {
- float2(0.3, 0.9),
- float2(0.3, -0.9),
- float2(0.9, 0.3),
- float2(-0.9, 0.3)
- };
- #endif
- #ifdef USE_ORIGINAL_OFFSETS
- const float2 offset[4]=
- {
- float2(0.0, 1.0),
- float2(0.0, -1.0),
- float2(1.0, 0.0),
- float2(-1.0, 0.0)
- };
- #endif
- #ifdef USE_WIDE_OFFSETS
- const float2 offset[4]=
- {
- float2(0.524, 1.282),
- float2(0.524, -1.282),
- float2(1.282, 0.524),
- float2(-1.282, 0.524)
- };
- #endif
- #ifdef USE_NATURAL_OFFSETS
- const float2 offset[16] = {
- float2(0.2007, 0.9796),
- float2(-0.2007, 0.9796),
- float2(0.2007, 0.9796),
- float2(-0.2007, 0.9796),
-
- float2(0.8240, 0.5665),
- float2(0.5665, 0.8240),
- float2(0.8240, 0.5665),
- float2(0.5665, 0.8240),
- float2(0.9796, 0.2007),
- float2(0.9796, -0.2007),
- float2(0.9796, 0.2007),
- float2(0.9796, -0.2007),
-
- float2(-0.8240, 0.5665),
- float2(-0.5665, 0.8240),
- float2(-0.8240, 0.5665),
- float2(-0.5665, 0.8240)
- };
- #endif
- float res=linearlizeDepth(tex2D(SamplerDepth, uvsrc.xy).x);
- for (int i=0; i<4; i++)
- {
- uvsrc.xy=uvsrc.xy;
- float FocusSampleRange =lerp( lerp( FocusSampleRangeDay, FocusSampleRangeNight, 1 - ENightDayFactor ), FocusSampleRangeInterior, EInteriorFactor);
- uvsrc.xy+=offset[i] * pixelSize.xy * FocusSampleRange;
- float DepthClip =lerp( lerp( DepthClipDay, DepthClipNight, 1 - ENightDayFactor ), DepthClipInterior, EInteriorFactor);
- #ifdef NOT_BLURRING_SKY_MODE
- res+=linearlizeDepth(tex2D(SamplerDepth, uvsrc).x);
- #else
- res+=min(linearlizeDepth(tex2D(SamplerDepth, uvsrc).x), DepthClip);
- #endif
- }
- res*=0.2; //.21 //.22
- return res;
- }
- float4 PS_WriteFocus(VS_OUTPUT_POST IN) : COLOR
- {
- float FocusPoint =lerp( lerp( FocusPointDay, FocusPointNight, 1 - ENightDayFactor ), FocusPointInterior, EInteriorFactor);
- float2 uvsrc=FocusPoint;
- float res=0.0;
- float curr=tex2D(SamplerCurr, uvsrc.xy).x;
- float prev=tex2D(SamplerPrev, uvsrc.xy).x;
-
- res=lerp(prev, curr, saturate(FadeFactor));//time elapsed factor
- return res;
- }
- technique ReadFocus
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_Focus();
- PixelShader = compile ps_3_0 PS_ReadFocus();
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- technique WriteFocus
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_Focus();
- PixelShader = compile ps_3_0 PS_WriteFocus();
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- 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;
- }
- float4 PS_ProcessPass1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float4 res;
- float2 coord=IN.txcoord.xy;
- float4 origcolor=tex2D(SamplerColor, coord.xy);
- float scenedepth=tex2D(SamplerDepth, IN.txcoord.xy).x;
- float scenefocus=tex2D(SamplerFocus, 0.5).x;
- res.xyz=origcolor.xyz;
- float depth=linearlizeDepth(scenedepth);
- float FarBlurCurve =lerp( lerp( FarBlurCurveDay, FarBlurCurveNight, 1 - ENightDayFactor ), FarBlurCurveInterior, EInteriorFactor);
- float FocalPlaneDepth =lerp( lerp( FocalPlaneDepthDay, FocalPlaneDepthNight, 1 - ENightDayFactor ), FocalPlaneDepthInterior, EInteriorFactor);
- float FarBlurDepth =lerp( lerp( FarBlurDepthDay, FarBlurDepthNight, 1 - ENightDayFactor ), FarBlurDepthInterior, EInteriorFactor);
- #ifdef AUTO_FOCUS
- float focalPlaneDepth=scenefocus;
- float farBlurDepth=scenefocus*pow(4.0, FarBlurCurve);
- #else
- float focalPlaneDepth=FocalPlaneDepth;
- float farBlurDepth=FarBlurDepth;
- #endif
-
- #ifdef TILT_SHIFT
- float TiltShiftAngle =lerp( lerp( TiltShiftAngleDay, TiltShiftAngleNight, 1 - ENightDayFactor ), TiltShiftAngleInterior, EInteriorFactor);
- float shiftAngle=(frac(TiltShiftAngle / 90.0) == 0) ? 0.0 : TiltShiftAngle;
- float depthShift=1.0 + (0.5 - coord.x)*tan(-shiftAngle * 0.017453292);
- focalPlaneDepth*=depthShift;
- farBlurDepth*=depthShift;
- #endif
-
-
- if(depth < focalPlaneDepth)
- res.w=(depth - focalPlaneDepth)/focalPlaneDepth;
- else
- {
- res.w=(depth - focalPlaneDepth)/(farBlurDepth - focalPlaneDepth);
- res.w=saturate(res.w);
- }
- res.w=res.w * 0.5 + 0.5;
-
- #ifdef NOT_BLURRING_SKY_MODE
- #define DEPTH_OF_FIELD_QUALITY 2 //[KYO : why 0 ?]
- //#define DEPTH_OF_FIELD_QUALITY 0
- res.w=(depth > 1000.0) ? 0.5 : res.w;
- #endif
-
- return res;
- }
- float4 PS_ProcessPass2(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float4 res;
-
- float2 coord=IN.txcoord.xy;
- float4 origcolor=tex2D(SamplerColor, coord.xy);
-
- float centerDepth=origcolor.w;
-
- float2 pixelSize=ScreenSize.y;
- pixelSize.y*=ScreenSize.z;
-
- float blurAmount=abs(centerDepth * 2.0 - 1.0);
- float discRadius=blurAmount * float(DEPTH_OF_FIELD_QUALITY);
- float RadiusScaleMultiplier =lerp( lerp( RadiusScaleMultiplierDay, RadiusScaleMultiplierNight, 1 - ENightDayFactor ), RadiusScaleMultiplierInterior, EInteriorFactor);
- float NearBlurCurve =lerp( lerp( NearBlurCurveDay, NearBlurCurveNight, 1 - ENightDayFactor ), NearBlurCurveInterior, EInteriorFactor);
- float BokehBias =lerp( lerp( BokehBiasDay, BokehBiasNight, 1 - ENightDayFactor ), BokehBiasInterior, EInteriorFactor);
- float BokehBrightnessThreshold =lerp( lerp( BokehBrightnessThresholdDay, BokehBrightnessThresholdNight, 1 - ENightDayFactor ), BokehBrightnessThresholdInterior, EInteriorFactor);
- float BokehBrightnessMultiplier =lerp( lerp( BokehBrightnessMultiplierDay, BokehBrightnessMultiplierNight, 1 - ENightDayFactor ), BokehBrightnessMultiplierInterior, EInteriorFactor);
- float BokehBiasCurve =lerp( lerp( BokehBiasCurveDay, BokehBiasCurveNight, 1 - ENightDayFactor ), BokehBiasCurveInterior, EInteriorFactor);
-
- discRadius*=RadiusScaleMultiplier;
-
- #ifdef AUTO_FOCUS
- discRadius*=(centerDepth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
- #endif
-
- res.xyz=origcolor.xyz;
- res.w=dot(res.xyz, 0.3333);
- res.w=max((res.w - BokehBrightnessThreshold) * BokehBrightnessMultiplier, 0.0);
- res.xyz*=1.0 + res.w*blurAmount;
-
- res.w=1.0;
-
- int sampleCycle=0;
- int sampleCycleCounter=0;
- int sampleCounterInCycle=0;
-
- #ifdef POLYGONAL_BOKEH
- float basedAngle=360.0 / POLYGON_NUM;
- float2 currentVertex;
- float2 nextVertex;
-
- int dofTaps=DEPTH_OF_FIELD_QUALITY * (DEPTH_OF_FIELD_QUALITY + 1) * POLYGON_NUM / 2.0;
- #else
- int dofTaps=DEPTH_OF_FIELD_QUALITY * (DEPTH_OF_FIELD_QUALITY + 1) * 4;
- #endif
-
-
- for(int i=0; i < dofTaps; i++)
- {
- if(sampleCounterInCycle % sampleCycle == 0)
- {
- sampleCounterInCycle=0;
- sampleCycleCounter++;
-
- #ifdef POLYGONAL_BOKEH
- sampleCycle+=POLYGON_NUM;
- currentVertex.xy=float2(1.0 , 0.0);
- sincos(basedAngle* 0.017453292, nextVertex.y, nextVertex.x);
- #else
- sampleCycle+=8;
- #endif
- }
- sampleCounterInCycle++;
-
- #ifdef POLYGONAL_BOKEH
- float sampleAngle=basedAngle / float(sampleCycleCounter) * sampleCounterInCycle;
- float remainAngle=frac(sampleAngle / basedAngle) * basedAngle;
-
- if(remainAngle == 0)
- {
- currentVertex=nextVertex;
- sincos((sampleAngle + basedAngle) * 0.017453292, nextVertex.y, nextVertex.x);
- }
- float2 sampleOffset=lerp(currentVertex.xy, nextVertex.xy, remainAngle / basedAngle);
- #else
- float sampleAngle=0.78539816 / float(sampleCycleCounter) * sampleCounterInCycle;
- float2 sampleOffset;
- sincos(sampleAngle, sampleOffset.y, sampleOffset.x);
- #endif
-
- sampleOffset*=sampleCycleCounter / float(DEPTH_OF_FIELD_QUALITY);
- float2 coordLow=coord.xy + (pixelSize.xy * sampleOffset.xy * discRadius);
- float4 tap=tex2D(SamplerColor, coordLow.xy);
-
- float weight=(tap.w >= centerDepth) ? 1.0 : abs(tap.w * 2.0 - 1.0);
-
- float luma=dot(tap.xyz, 0.3333);
- float brightMultiplier=max((luma - BokehBrightnessThreshold) * BokehBrightnessMultiplier, 0.0);
- tap.xyz*=1.0 + brightMultiplier*abs(tap.w*2.0 - 1.0);
-
- tap.xyz*=1.0 + BokehBias * pow(float(sampleCycleCounter)/float(DEPTH_OF_FIELD_QUALITY), BokehBiasCurve);
-
- res.xyz+=tap.xyz * weight;
- res.w+=weight;
- }
- res.xyz /= res.w;
-
- res.w=centerDepth;
- return res;
- }
- float4 PS_ProcessPass3(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float RadiusScaleMultiplier =lerp( lerp( RadiusScaleMultiplierDay, RadiusScaleMultiplierNight, 1 - ENightDayFactor ), RadiusScaleMultiplierInterior, EInteriorFactor);
- float2 coord=IN.txcoord.xy;
- float2 pixelSize=ScreenSize.y;
- pixelSize.y*=ScreenSize.z;
-
- float4 origcolor=tex2D(SamplerColor, coord.xy);
- float depth=origcolor.w;
- float blurAmount=abs(depth * 2.0 - 1.0);
- float discRadius=blurAmount * float(DEPTH_OF_FIELD_QUALITY) * RadiusScaleMultiplier;
- float NearBlurCurve =lerp( lerp( NearBlurCurveDay, NearBlurCurveNight, 1 - ENightDayFactor ), NearBlurCurveInterior, EInteriorFactor);
- #ifdef AUTO_FOCUS
- discRadius*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
- #endif
-
- float4 res=origcolor;
- float3 distortion=float3(-1.0, 0.0, 1.0);
- float ChromaticAberrationAmount =lerp( lerp( ChromaticAberrationAmountDay, ChromaticAberrationAmountNight, 1 - ENightDayFactor ), ChromaticAberrationAmountInterior, EInteriorFactor);
- distortion*=ChromaticAberrationAmount*discRadius;
- origcolor=tex2D(SamplerColor, coord.xy + pixelSize.xy*distortion.x);
- origcolor.w=smoothstep(0.0, depth, origcolor.w);
- res.x=lerp(res.x, origcolor.x, origcolor.w);
-
- origcolor=tex2D(SamplerColor, coord.xy + pixelSize.xy*distortion.z);
- origcolor.w=smoothstep(0.0, depth, origcolor.w);
- res.z=lerp(res.z, origcolor.z, origcolor.w);
- return res;
- }
- float4 PS_ProcessPass4(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float2 coord=IN.txcoord.xy;
-
- float2 pixelSize=ScreenSize.y;
- pixelSize.y*=ScreenSize.z;
-
- float4 origcolor=tex2D(SamplerColor, coord.xy);
- float depth=origcolor.w;
- float blurAmount=abs(depth*2.0 - 1.0);
- float NearBlurCurve =lerp( lerp( NearBlurCurveDay, NearBlurCurveNight, 1 - ENightDayFactor ), NearBlurCurveInterior, EInteriorFactor);
- #if (DEPTH_OF_FIELD_QUALITY > 0)
- #ifdef AUTO_FOCUS
- blurAmount*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
- #endif
- blurAmount=smoothstep(0.15, 1.0, blurAmount);
- #endif
-
- float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541,
- 0.0162162162};
-
- float4 res=origcolor * weight[0];
-
- for(int i=1; i < 5; i++)
- {
- res+=tex2D(SamplerColor, coord.xy + float2(i*pixelSize.x*blurAmount, 0)) * weight[i];
- res+=tex2D(SamplerColor, coord.xy - float2(i*pixelSize.x*blurAmount, 0)) * weight[i];
- }
-
- res.w=depth;
-
- return res;
- }
- float4 PS_ProcessPass5(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
- {
- float2 coord=IN.txcoord.xy;
-
- float2 pixelSize=ScreenSize.y;
- pixelSize.y*=ScreenSize.z;
-
- float4 origcolor=tex2D(SamplerColor, coord.xy);
- float depth=origcolor.w;
- float blurAmount=abs(depth*2.0 - 1.0);
- float NearBlurCurve =lerp( lerp( NearBlurCurveDay, NearBlurCurveNight, 1 - ENightDayFactor ), NearBlurCurveInterior, EInteriorFactor);
-
- #if (DEPTH_OF_FIELD_QUALITY > 0)
- #ifdef AUTO_FOCUS
- blurAmount*=(depth < 0.5) ? (1.0 / max(NearBlurCurve, 1.0)) : 1.0;
- #endif
- blurAmount=smoothstep(0.15, 1.0, blurAmount);
- #endif
-
- float weight[5] = {0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541,
- 0.0162162162};
- float4 res=origcolor * weight[0];
- for(int i=1; i < 5; i++)
- {
- res+=tex2D(SamplerColor, coord.xy + float2(0, i*pixelSize.y*blurAmount)) * weight[i];
- res+=tex2D(SamplerColor, coord.xy - float2(0, i*pixelSize.y*blurAmount)) * weight[i];
- }
-
- float origgray=dot(res.xyz, 0.3333);
- origgray/=origgray + 1.0;
- coord.xy=IN.txcoord.xy*16.0 + origgray;
- float4 cnoi=tex2D(SamplerNoise, coord);
- float noiseAmount=NoiseAmount*pow(blurAmount, NoiseCurve);
- //res=lerp(res, (cnoi.x+0.5)*res, noiseAmount*saturate(1.0-origgray*1.8));
- //res=lerp(res, (cnoi.x+0.5)*res, noiseAmount*saturate(1.0-origgray*0.5));
- float NoiseDiffusion =lerp( lerp( NoiseDiffusionDay, NoiseDiffusionNight, 1 - ENightDayFactor ), NoiseDiffusionInterior, EInteriorFactor);
- res=lerp(res, (cnoi.x+0.5)*res, noiseAmount*saturate(1.0-origgray*NoiseDiffusion));
-
- res.w=depth;
-
- return res;
- }
- technique PostProcess
- {
- pass P0
- {
- VertexShader = compile vs_3_0 VS_PostProcess();
- PixelShader = compile ps_3_0 PS_ProcessPass1();
- 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_ProcessPass2();
- 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_ProcessPass3();
- 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_ProcessPass4();
- 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_ProcessPass5();
- DitherEnable=FALSE;
- ZEnable=FALSE;
- CullMode=NONE;
- ALPHATESTENABLE=FALSE;
- SEPARATEALPHABLENDENABLE=FALSE;
- AlphaBlendEnable=FALSE;
- StencilEnable=FALSE;
- FogEnable=FALSE;
- SRGBWRITEENABLE=FALSE;
- }
- }
- //+++++++++++++++++++++++++++
- //Modified by Unreal Warfare
- //+++++++++++++++++++++++++++
|