Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author: CeeJay.dk
- // Title: LumaSharpen
- // Pack: SweetFX
- // Desc:
- // Sharpens the image
- // This is simplified version of the LumaSharpen found in SweetFX
- //Settings :
- static const float sharp_strength = 0.60; //Sharpening strength
- static const float sharp_clamp = 0.035; //Clamp the max sharpening to prevent halo artifacts
- //Code :
- texture lastpass;
- sampler s0 = sampler_state { texture=<lastpass>; minfilter = linear; magfilter = linear; mipfilter = linear; addressu=clamp; addressv = clamp; };
- vector rcpres;
- float4 LumaSharpen(in float2 Tex : TEXCOORD) : COLOR0
- {
- float4 inColor = tex2D(s0, Tex);
- float3 blur = tex2D(s0, Tex + float2(0.5 * rcpres.xy)).rgb;
- blur += tex2D(s0, Tex + float2(-0.5 * rcpres.xy)).rgb;
- blur += tex2D(s0, Tex + float2(0.5 * rcpres.x,-0.5 * rcpres.y)).rgb;
- blur += tex2D(s0, Tex + float2(-0.5 * rcpres.x,0.5 * rcpres.y)).rgb;
- blur /= 4.0;
- float3 sharp = inColor.rgb - blur;
- static const float3 CoefLuma = float3(0.2126, 0.7152, 0.0722); //luma conversion values
- float3 sharp_strength_luma = (sharp_strength * CoefLuma);
- // -- Adjust strength of the sharpening --
- float sharp_luma = dot(sharp, sharp_strength_luma); //Calculate the luma and adjust the strength
- // -- Clamping the maximum amount of sharpening to prevent halo artifacts --
- sharp_luma = clamp(sharp_luma, -sharp_clamp, sharp_clamp); //
- inColor.rgb = inColor.rgb + sharp_luma;
- return inColor;
- }
- technique T0 < string MGEinterface="MGE XE 0"; >
- {
- pass p0
- {
- PixelShader = compile ps_3_0 LumaSharpen();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement