//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //ENBSeries: boris-vorontsov@yandex.ru, boris-vorontsov.narod.ru //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /* THIS IS HLSL (HIGH LEVEL SHADER LANGUAGE) FILE FOR EXECUTING ADDITIONAL HARDWARE EFFECTS. MAKE THE COPY BEFORE CHANGING IT! */ //keyboard controled variables float tempF1; float tempF2; float tempF3; float tempF4; float tempF5; float tempF6; float tempF7; float tempF8; float tempF9; float tempF0; //global variables, already set before executing this code float ScreenSize; //width of the display resolution (1024 f.e.) float ScreenScaleY; //screen proportions (1.333 for 1024/768) float4 ScreenBrightness;//rgba(0..1) color of the screen with time dependent inertia float ScreenBrightnessAdaptation;//(-10..10) for bloom it controls how much to dark in the night or when scene is dark (user defined constant factor) float bloomPower;//(0..10) actually used for bloom, but may be useful here (user defined constant factor) float useBloom;//(0 or 1) if bloom enabled by user //textures texture2D texColor; sampler2D SamplerColor = sampler_state { Texture = ; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR;//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 normalPS_PostProcess(VS_OUTPUT_POST In) : COLOR { float offset = 1 / ScreenSize; float power = 0.5 * tempF0; float4 colx = float4(0,0,0,0); float4 coly = colx; float alpha = colx.w; int margin = 5; float coeff = 2 * tempF9; for(int i = 1; i < margin; i++) coly -= tex2D(SamplerColor, In.txcoord + float2(0, -offset * i)) / pow(i, coeff); for(int i = 1; i < margin; i++) coly += tex2D(SamplerColor, In.txcoord + float2(0, offset * i)) / pow(i, coeff); for(int i = 1; i < margin; i++) colx -= tex2D(SamplerColor, In.txcoord + float2(-offset * i, 0)) / pow(i, coeff); for(int i = 1; i < margin; i++) colx += tex2D(SamplerColor, In.txcoord + float2(offset * i, 0)) / pow(i, coeff); float x = (colx.r+colx.g+colx.b) / 3; float y = (coly.r+coly.g+coly.b) / 3; float z = (x+y)/2; return tex2D(SamplerColor, In.txcoord)+power*float4(z,z,z, alpha); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ technique PostProcess { pass P0 { VertexShader = compile vs_2_0 VS_PostProcess(); PixelShader = compile ps_2_0 normalPS_PostProcess(); ALPHATESTENABLE=FALSE; SEPARATEALPHABLENDENABLE=FALSE; AlphaBlendEnable=FALSE; FogEnable=FALSE; SRGBWRITEENABLE=FALSE; } }