Jump to content

ENB DoF Pink Discolouration


ZoSo94

Recommended Posts

I've put two images here, when you can see where the DoF of my ENB is giving off a strange pink colouring around the edges.

http://i.imgur.com/k6qtjIF.jpg

 

http://i.imgur.com/QfobdPm.jpg

 

 

The second picture is with DoF on and you can see especially on the rollercoaster that it is pink. My DoF settings are below, is there anything I can change to get rid of the colouring?

 

 

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// ENBSeries effect file
// visit http://enbdev.com for updates
// Copyright © 2007-2011 Boris Vorontsov
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
////////////////////////////////////////////////////////////////////
// Based on:
// Bokeh Depth Of Field 0915v2 by gp65cj04
////////////////////////////////////////////////////////////////////
// Some things are from:
// ENBSeries Modifications 2.0.5 by Matso
// Modifed by Michael Tichenor (IndigoNeko)
////////////////////////////////////////////////////////////////////
//Constants
#define PI 3.1415926535897932384626433832795
#define PI_OVER_180 0.01745329251994329576923690768489
//+++++++++++++++++++++++++++++
//internal parameters, can be modified
//+++++++++++++++++++++++++++++
#define DEPTH_OF_FIELD_QULITY 5
#define AUTO_FOCUS
//#define TILT_SHIFT
#define POLYGONAL_BOKEH
#define POLYGON_NUM 5
#define CHROMATIC_ABBERATION
#define NOISE
// Auto focus settings
// NOTE: Focuses on the nearest of all points sampled
float2 FocusPoint = float2(0.5, 0.5); //Focusing area center ( 0,0 - upper left; 1,1 down right).
//Default: 0.5, 0.5
float FocusSampleRange = 0.02; //Focusing area radius. Default: 0.02
float FocusMinDistance = 0.1; //Won't focus nearer than this distance (m). Default: 0.1
float FocusMaxDistance = 40.0; //Won't focus farther than this distance (m). Default: 200.0
// Manual focus settings
// NOTE: Hold 0 + PG UP or PG DN to adjust manual camera focus distance in-game.
// Use Shift+Enter -> TempVariables -> Value 0 to directly control distance multiplier value.
float ManualFocusDepth = 1.00; //Initial distance to focus plane (m). Default: 0.5; Key: 0
// Tilt-Shift settings
// NOTE: Better to use with manual focus
// NOTE: Hold 8 + PG UP or PG DN to adjust tilt angle in-game.
// Use Shift+Enter -> TempVariables -> Value 8 to directly control tilt angle offset value.
// NOTE: Hold 7 + PG UP or PG DN to adjust tilt axis vertical position in-game.
// Use Shift+Enter -> TempVariables -> Value 7 to directly control axis position offset value.
float TiltShiftAngle = 0.0; //Initial light sensor matrix plane tilt angle (degrees, 0 - no tilt)
//Default: 1.0; Key: 8
float TiltShiftAxis = 0.5; //Tilt axis vertical position (0.5 - center of the frame)
//Default: 0.5; Key: 7
// Bokeh settings
float BokehBias = 0.5; // Positive for hard bokeh edges. Range: [-1.0, 1.0]; Default: 0.5
float BokehBiasCurve = 1.0; // Must be greater than zero. Default: 0.5
int PolygonRotation = 10.0; // Polygon rotation (clockwise, 0.0 means 1st vertex is up)
// Camera Lens settings
//NOTE: Assuming simple thin-lens camera with variable focal length of the lens,
// fixed lens to film distance and fixed aperture.
//float FocalLength=50.0; //Not fixed for this type of camera
// NOTE: Hold 8 + PG UP or PG DN to adjust aperture
// Use Shift+Enter -> TempVariables -> Value 8 to directly control aperture multiplier value.
float Aperture = 12.0; //Camera aperture size (mm). Default: 12.0; Key: 8
//For constant FOV
//float FilmDistance = 50.0; //Distance from lens back plane to the film (mm). Default: 50.0
//For variable FOV //WIP
float FilmHeight = 35.0; //Camera light sensor matrix height (mm). Default: 35.0
// Noise grain settings
float NoiseAmount = 0.10; //Maximum amount of noise. Default: 0.35
float NoiseCurve = 1.00; //Default: 0.5
// Chromatic abberation settings
float ChromaticAberrationAmount = 0.002; //DOF-unrelated Chromatic aberration amount multiplier.
//Default: 0.001
float DOFChromaticAberrationAmount = 0.0005; //DOF-related Chromatic aberration amount multiplier.
//Default: 0.0005
// Other
float MaxBlurRadius = 32.0; //Blur radius upper limit (will be clamped to this value)
//+++++++++++++++++++++++++++++
//external parameters, do not modify
//+++++++++++++++++++++++++++++
//keyboard controlled temporary variables (in some versions exists in the config file). 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
//x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
float4 ScreenSize;
//x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
float4 Timer;
//adaptation delta time for focusing
float FadeFactor;
// Calculated
float FOV = 65.0; //TODO: Get actual FOV value //Ingame horizontal FOV (degrees)
//textures
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;//NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
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;
};
//for focus computation
sampler2D SamplerCurr = sampler_state
{
Texture = <texCurr>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;//NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
//for focus computation
sampler2D SamplerPrev = sampler_state
{
Texture = <texPrev>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Clamp;
AddressV = Clamp;
SRGBTexture=FALSE;
MaxMipLevel=0;
MipMapLodBias=0;
};
//for dof only in PostProcess techniques
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;
};
////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////
float DepthToDistance(float Depth)
{
const float zFar = 3000.0; //3098.0392;
const float zNear = 0.15; //0.0509804;
if( Depth < 1.0 && Depth >= 0.0 )
{
return min( zFar, ( zNear / ( 1.0 - Depth ) ) );
//return zFar / (zNear - (zFar-zNear)/zNear * Depth);
//return 1.0 / (1.0 / zFar - (zFar-zNear)/(zNear*zFar) * Depth);
}
return zFar;
}
/* float DepthToDistance(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;
} */
// IEC 61966-2-1 sRGB Specification for Luminance.
// float Luminance(float3 Color)
// {
// float3 sRGB = float3(0.2125, 0.7154, 0.0721);
// return dot(Color, sRGB);
// }
////////////////////////////////////////////////////////////////////
//begin focusing code
////////////////////////////////////////////////////////////////////
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;
}
//SRCpass1X=ScreenWidth;
//SRCpass1Y=ScreenHeight;
//DESTpass2X=4;
//DESTpass2Y=4;
float4 PS_ReadFocus(VS_OUTPUT_POST IN) : COLOR
{
float2 uvsrc=FocusPoint;
const float2 offset[4]=
{
float2(0.0, 1.0),
float2(0.0, -1.0),
float2(1.0, 0.0),
float2(-1.0, 0.0)
};
float res=tex2D(SamplerDepth, uvsrc.xy).x;
for (int i=0; i<4; i++)
{
uvsrc.xy=uvsrc.xy;
uvsrc.xy+=offset * FocusSampleRange;
res=min(res, tex2D(SamplerDepth, uvsrc).x);
}
res = DepthToDistance(res);
res = min(res, FocusMaxDistance);
res = max(res, FocusMinDistance);
return res;
}
//SRCpass1X=4;
//SRCpass1Y=4;
//DESTpass2X=4;
//DESTpass2Y=4;
float4 PS_WriteFocus(VS_OUTPUT_POST IN) : COLOR
{
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, pow(saturate(FadeFactor),(prev < curr) ? 2.0 : 1.0));//time elapsed factor
float step = (prev+0.01)*saturate(FadeFactor)*sign(curr-prev);
res = (abs(curr - prev) > abs(step)) ? prev + step : curr;
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;
}
}
////////////////////////////////////////////////////////////////////
//end focusing code
////////////////////////////////////////////////////////////////////
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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, coord.xy).x;
float scenefocus=tex2D(SamplerFocus, 0.5).x;
res.xyz=origcolor.xyz;
float ObjectDistance=DepthToDistance(scenedepth);
#ifdef AUTO_FOCUS
float FocusDistance=scenefocus;
#else
float FocusDistance=ManualFocusDepth * tempF3.y;
#endif
//WIP
#ifdef TILT_SHIFT
//tempF2.w default value is -1 (PgUP to decrease)
float tiltAngle = clamp(TiltShiftAngle + (abs(tempF2.w)-1.0), -60.0, 60.0);
float tiltAxis = TiltShiftAxis - 1.0 + tempF2.z;
#endif
float FilmDistance = FilmHeight * ScreenSize.w / tan(FOV * PI_OVER_180);
float FocalLength = FocusDistance * 0.001 * FilmDistance / (FocusDistance + 0.001 * FilmDistance);
//Aperture in-game control
float aperture = Aperture * tempF2.w;
res.w = aperture * ((FocusDistance * (ObjectDistance - FocalLength)) /
(ObjectDistance * (FocusDistance - FocalLength)) - 1.0);
#ifdef TILT_SHIFT
//Apply Tilt-Shift
res.w += (coord.y - tiltAxis) * tan(-tiltAngle * PI_OVER_180);
#endif
// Dots per mm = 1 / pixel size in mm
float dpmm = ScreenSize.x*ScreenSize.z / FilmHeight;
// in pixels
res.w = res.w * dpmm;
// no need to scale to [-1;1]. it's HDR!
// clamped from -1 to 1 (to limit the blur)
// res.w=clamp(res.w / MaxBlurRadius, -1.0, 1.0);
// clamped from -MaxBlurRadius to MaxBlurRadius (to limit the blur)
//res.w=clamp(res.w , -MaxBlurRadius, MaxBlurRadius);
#ifdef CHROMATIC_ABBERATION
//chromatic abberation
float discRadius=abs(clamp(res.w, -MaxBlurRadius, MaxBlurRadius));// * float(DEPTH_OF_FIELD_QULITY);
float2 coordCenter = float2(0.5, 0.5);
float2 coordOffset = coord.xy - coordCenter.xy;
res.x = tex2D(SamplerColor, coordCenter.xy +
coordOffset.xy * (1.0 - ChromaticAberrationAmount
- DOFChromaticAberrationAmount * discRadius)).x;
res.z = tex2D(SamplerColor, coordCenter.xy +
coordOffset.xy * (1.0 + ChromaticAberrationAmount
+ DOFChromaticAberrationAmount * discRadius)).z;
#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 cof = origcolor.w; //center out of focus value
float2 pixelSize=ScreenSize.y;
pixelSize.y*=ScreenSize.z;
//float blurAmount=abs(centerDepth * 2.0 - 1.0);
//float blurAmount=4.0;//abs(CoCFactor * 2.0 - 1.0);
float discRadius=abs(clamp(cof,-MaxBlurRadius,MaxBlurRadius));// * float(DEPTH_OF_FIELD_QULITY);
//discRadius*=RadiusSacleMultipiler;
//discRadius*=Aperture;
res.xyz=origcolor.xyz;
//res.w=dot(res.xyz, 0.3333);
//res.w=max((res.w - BokehBrightnessThreshold) * BokehBrightnessMultipiler, 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;
float polygonRotation = 90.0 + PolygonRotation;
float2 currentVertex;
float2 nextVertex;
int dofTaps=DEPTH_OF_FIELD_QULITY * (DEPTH_OF_FIELD_QULITY + 1) * POLYGON_NUM / 2.0;
#else
int dofTaps=DEPTH_OF_FIELD_QULITY * (DEPTH_OF_FIELD_QULITY + 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((polygonRotation) * PI_OVER_180, currentVertex.y, currentVertex.x); //rotate bokeh
sincos((basedAngle + polygonRotation) * PI_OVER_180, 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 + polygonRotation) * PI_OVER_180, 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
float sampleOffsetLength = float(sampleCycleCounter) / float(DEPTH_OF_FIELD_QULITY);
sampleOffset*=sampleOffsetLength;
float2 coordLow=coord.xy + (pixelSize.xy * sampleOffset.xy * discRadius);
float4 tap=tex2D(SamplerColor, coordLow.xy);
sampleOffsetLength*=discRadius;
//float tapOffset = length(sampleOffset.xy * discRadius);
//float weight=(tap.w >= centerDepth) ? 1.0 : abs(tap.w * 2.0 - 1.0);
//float weight=1.0;//(tap.w >= CoCFactor) ? 1.0 : abs(tap.w * 2.0 - 1.0);
float weight=1.0;
//weight*=(cof < tap.w) ? saturate(-abs(tap.w) * tap.w * 0.01) : 1.0;
//weight*=(cof < tap.w) ? saturate(tap.w * tap.w * 0.01) : 1.0;
weight*=(cof < tap.w && abs(tap.w) < sampleOffsetLength) ? saturate(-abs(tap.w) * tap.w * 0.01) : 1.0;
//float luma=dot(tap.xyz, 0.3333);
//float brightMultipiler=max((luma - BokehBrightnessThreshold) * BokehBrightnessMultipiler, 0.0);
//tap.xyz*=1.0 + brightMultipiler*abs(tap.w*2.0 - 1.0);
//tap.xyz*=1.0 + BokehBias * pow(sampleOffsetLength, BokehBiasCurve);
//weight*=saturate(1.0 + BokehBiasMultiplier * pow(float(sampleCycleCounter)/float(DEPTH_OF_FIELD_QULITY), BokehBiasCurve));
// float BokehBias = tempF1.x - 1.0; //key 1
// float BokehBiasCurve = tempF1.y; // key 2
float BokehBiasCenter = (BokehBias > 0) ? 1.0 - BokehBias : 1.0;
weight *= saturate(BokehBiasCenter + (sampleOffsetLength*sampleOffsetLength * BokehBias*BokehBias)
/((BokehBiasCurve - 2) * (1.0 - sampleOffsetLength + BokehBias / (BokehBiasCurve - 2))));
res.xyz+=tap.xyz * weight;
res.w+=weight;
}
res.xyz /= res.w;
//res.z=saturate((cof > 0) ? 1.0 : res.z);
//res.w=centerDepth;
res.w=cof;
return res;
}
//DOF chromatic abberation
// float4 PS_ProcessPass3(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 CoCFactor=origcolor.w;
// //float blurAmount=abs(depth * 2.0 - 1.0);
// float blurAmount=abs(CoCFactor * 2.0 - 1.0);
// float discRadius=blurAmount * float(DEPTH_OF_FIELD_QULITY) * RadiusSacleMultipiler;
// //#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);
// distortion*=ChromaticAberrationAmount*discRadius;
// origcolor=tex2D(SamplerColor, coord.xy + pixelSize.xy*distortion.x);
// //origcolor.w=smoothstep(0.0, depth, origcolor.w);
// origcolor.w=smoothstep(0.0, CoCFactor, 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);
// origcolor.w=smoothstep(0.0, CoCFactor, 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 cof=origcolor.w;
float blurAmount=clamp(abs(cof), 0.0, MaxBlurRadius);
#if (DEPTH_OF_FIELD_QULITY > 0)
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;
res+=tex2D(SamplerColor, coord.xy - float2(i*pixelSize.x*blurAmount, 0)) * weight;
}
res.w=cof;
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 cof=origcolor.w;
float blurAmount=clamp(abs(cof), 0.0, MaxBlurRadius);
#if (DEPTH_OF_FIELD_QULITY > 0)
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;
res+=tex2D(SamplerColor, coord.xy - float2(0, i*pixelSize.y*blurAmount)) * weight;
}
#ifdef NOISE
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));
#endif
res.w=cof;
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 PostProcess3
{
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 PostProcess4
{
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;
}
}

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...