//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //ENBSeries: boris-vorontsov@yandex.ru, boris-vorontsov.narod.ru //Modifications by Honken and fox //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //Keyboard variables, change with shift + 1 + PG{UP|Down} float tempF1; //Controls screen brightness //global variable, already set before executing this code float ScreenSize; //width of the display resolution //Textures texture2D texColor; texture2D texBloom; sampler2D SamplerColor = sampler_state { Texture = ; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = Clamp; AddressV = Clamp; SRGBTexture = FALSE; }; sampler2D SamplerBloom = sampler_state { Texture = ; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = NONE; AddressU = Clamp; AddressV = Clamp; SRGBTexture = FALSE; }; 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; } float4 PS_PostProcess(VS_OUTPUT_POST In) : COLOR { float2 offset[4]= { float2(-1.0,-1.0), float2(-1.0, 1.0), float2( 1.0, 1.0), float2( 1.0,-1.0) }; float4 res=0.0; float4 coord=0.0; coord.xy=In.txcoord.xy; float4 origcolor=tex2D(SamplerColor, coord.xy); float origgray=max(origcolor.r, max(origcolor.g, origcolor.b)); res+=origcolor; float range=0.7/ScreenSize; for (int i=0; i<4; i++) { coord.xy=In.txcoord+offset[i] *range; float4 color; float gray; color=tex2D(SamplerColor, coord.xy); float4 colordiff=abs(origcolor-color); gray=dot(colordiff.rgb,0.3); float lerpfact=saturate(4.0*abs(gray)*color.a); res+=lerp(origcolor, color, lerpfact); } res=res*0.2; coord.xy=In.txcoord.xy; coord.w=4; float4 envcol1=tex2D(SamplerColor, coord); coord.w=6; float4 envcol2=tex2D(SamplerColor, coord); float4 envcol3=tex2D(SamplerBloom, coord); float4 envcol=(envcol1+envcol2+envcol3)*0.7; //envcol=pow(envcol, 2*tempF1 ); envcol=envcol*1.08; res=lerp(envcol, res*envcol, 0.1f ); float middlegray=(res.r+res.g+res.b)*0.3; float3 diffcolor=res.rgb-middlegray; res.rgb-=diffcolor*0.3; res.a=1.0; return res; } technique PostProcess { pass P0 { VertexShader = compile vs_2_0 VS_PostProcess(); PixelShader = compile ps_2_0 PS_PostProcess(); FogEnable=FALSE; ALPHATESTENABLE=FALSE; SEPARATEALPHABLENDENABLE=FALSE; AlphaBlendEnable=TRUE; SRGBWRITEENABLE=FALSE; } }