struct VS_OUT { float4 hPosition : POSITION; float2 texCoord : TEXCOORD0; }; VS_OUT Default_VS(float4 position : POSITION, float4 texCoord : TEXCOORD0) { VS_OUT OUT; OUT.hPosition = float4(sign(position.xy),0,1); OUT.texCoord = (float2(OUT.hPosition.x, -OUT.hPosition.y) + 1.0) / 2.0; return OUT; } float4 Black_PS(VS_OUT IN):COLOR { return float4(0,0,0,1); } float4 Copy_PS(VS_OUT IN, uniform float width, uniform float height, uniform sampler2D Texture: register(s0)) : COLOR { IN.texCoord += float2(0.5/width, 0.5/height); // return 1; return tex2D(Texture, IN.texCoord); } float4 AlphaBlend_PS(VS_OUT IN, uniform float width, uniform float height, uniform float alpha, uniform sampler2D Texture: register(s0)) : COLOR { IN.texCoord += float2(0.5/width, 0.5/height); return float4(tex2D(Texture, IN.texCoord).rgb, alpha); } float4 Add_PS(VS_OUT IN, uniform float width, uniform float height, uniform sampler2D Texture1: register(s0), uniform sampler2D Texture2: register(s1) ):COLOR { IN.texCoord += float2(0.5/width, 0.5/height); return tex2D(Texture1,IN.texCoord ) + tex2D(Texture2,IN.texCoord ); } float4 Combine_PS(VS_OUT IN, uniform float width, uniform float height, uniform float weight1, uniform float weight2, uniform sampler2D Texture1: register(s0), uniform sampler2D Texture2: register(s1) ):COLOR { IN.texCoord += float2(0.5/width, 0.5/height); return tex2D(Texture1,IN.texCoord ) * weight1 + tex2D(Texture2,IN.texCoord ) * weight2; } half4 Luminance_PS(VS_OUT IN, uniform half width, uniform half height, uniform sampler2D Texture: register(s0) ):COLOR { IN.texCoord += half2(0.5/width, 0.5/height); half4 sample = tex2D(Texture,IN.texCoord ); // D65 white conversion and weighting half avg = sample.r * 0.21f + sample.g * 0.39f + sample.b * 0.4f; return half4(avg, 0, 0, 1); } float4 GlowCut_PS(VS_OUT IN, uniform float width, uniform float height, uniform float cutValue, uniform float timeBlur, uniform sampler2D Texture: register(s0) ,uniform sampler2D LastTexture: register(s1) ):COLOR { IN.texCoord += float2(0.5/width, 0.5/height); float4 sample = 2.0 * tex2D(Texture,IN.texCoord ); float luminance = dot(sample.rgb, float3(1.0, 4.5907, 0.0601)); if (luminance < cutValue) sample = float4(0,0,0,0); float alpha = timeBlur; sample = sample * alpha + tex2D(LastTexture, IN.texCoord) * (1.0 - alpha); return sample; } float4 GlowBlurH_PS(VS_OUT IN, uniform float Stretch, uniform float width, uniform float height, uniform float timeBlur, uniform sampler2D Texture: register(s0)) : COLOR { float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height); float4 texLookUp_h; /*texLookUp_h = tex2D(Texture, float2(tex0.x-(3.86979f*Stretch/width), tex0.y)) + tex2D(Texture, float2(tex0.x-(1.72291f*Stretch/width ), tex0.y)) + tex2D(Texture, tex0) + tex2D(Texture, float2(tex0.x+(1.72291f*Stretch/width), tex0.y)) + tex2D(Texture, float2(tex0.x+(3.86979f*Stretch/width), tex0.y));*/ texLookUp_h = tex2D(Texture, float2(tex0.x-(2.0*Stretch/width), tex0.y)) + tex2D(Texture, float2(tex0.x-(1.0*Stretch/width ), tex0.y)) + tex2D(Texture, tex0) + tex2D(Texture, float2(tex0.x+(1.0*Stretch/width), tex0.y)) + tex2D(Texture, float2(tex0.x+(2.0*Stretch/width), tex0.y)); return float4(texLookUp_h.rgb / 5.0, timeBlur) ; } float4 GlowBlurV_PS(VS_OUT IN, uniform float Stretch, uniform float width, uniform float height, uniform float timeBlur, uniform sampler2D Texture: register(s0)) : COLOR { float2 tex0 = IN.texCoord + float2(0.5/width, 0.5/height); float4 texLookUp_v; /*texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(3.86979f*Stretch/height)))+ tex2D(Texture, float2(tex0.x, tex0.y-(1.72291f*Stretch/height)))+ tex2D(Texture, tex0)+ tex2D(Texture, float2(tex0.x, tex0.y+(1.72291f*Stretch/height)))+ tex2D(Texture, float2(tex0.x, tex0.y+(3.86979f*Stretch/height)));*/ texLookUp_v = tex2D(Texture, float2(tex0.x, tex0.y-(2*Stretch/height))) + tex2D(Texture, float2(tex0.x, tex0.y-(1*Stretch/height))) + tex2D(Texture, tex0) + tex2D(Texture, float2(tex0.x, tex0.y+(1*Stretch/height))) + tex2D(Texture, float2(tex0.x, tex0.y+(2*Stretch/height))); return float4(texLookUp_v.rgb / 5.0, timeBlur); } float4 ToneMap_PS(VS_OUT IN, uniform half width, uniform half height, uniform half Gain, uniform sampler2D Scene: register(s0), uniform sampler2D AvrLuminanceTexture: register(s1), uniform sampler2D LuminanceTexture: register(s2), uniform sampler2D GlobalLuminanceTexture: register(s3) ):COLOR { IN.texCoord += half2(0.5/width, 0.5/height); float gLum = tex2D(GlobalLuminanceTexture, float2(0.5,0.5)).r; gLum = max(gLum, 0.31415); // Automatic key calculation //half Key = 1.03f - 2.0f / (2.0f + log10(tex2D(AvrLuminanceTexture, IN.texCoord).r + 1.0f)); //half Key = 1 / (tex2D(AvrLuminanceTexture, IN.texCoord).r / 1 + tex2D(AvrLuminanceTexture, IN.texCoord).r); //return 1 / Key; // Relative luminance //half RelLum = Key* tex2D(LuminanceTexture, IN.texCoord).r / // tex2D(AvrLuminanceTexture, IN.texCoord).r; half Key = 1.03f - 2.0f / (2.0f + log10(gLum + 1.0f)); half RelLum = Key* tex2D(LuminanceTexture, IN.texCoord).r / gLum; half Lum = RelLum / (1 + RelLum); // Color weghting half4 Color = tex2D(Scene, IN.texCoord) / gLum * 0.4f; // Gamma correction //Color = pow(Color * half4(1.05f, 0.97f, 1.27f, 1.0f), Gain); return Color + 0.0000000000001 * Gain; //return gLum; return float4(tex2D(GlobalLuminanceTexture, IN.texCoord).r, tex2D(GlobalLuminanceTexture, IN.texCoord).r, tex2D(GlobalLuminanceTexture, IN.texCoord).r, 1); }