0% found this document useful (0 votes)
15 views3 pages

Effect

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Effect

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// Tonemapping, Sharpen, and Desaturation effects for SA - DKT70 - Feb 2011.

// HDR Settings.
float Defog=0.000; // Strength of FogColor, higher = more.
float4 FogColor={0.0, 0.0, 0.0, 0.0}; // Lens-style color filters for Blue, Red,
Yellow, White.
float Exposure=0.2; // Contrast settings, higher = brighter, but also more white.
float Gamma=0.2; // Gamma settings for darker or lighter shadows and dark areas,
higher = darker.
float BlueShift=0.10; // Shifts entire color spectrum towards blue, good for images
too yellow, but this is global.

// Saturation Levels.
float sat = -0.7; // Saturation levels, higher values = less saturation, 0 = off.

// Sharpen effect settings. For some good settings try using double your resolution
in sxres and syres, and keep sharp strength double the offset.
float sharps = 0.00; // Sharpen Strength.
float offsetv = 0.60; // Offset value, higher = more offset from center.
float sxres = 2560; // Horizontal Resolution setting.
float syres = 2048; // Vertical Resolution setting.
float aspect = 1.25; // Aspect Ratio.

//---------------------------------------------------------------------------------
-----
// Textures
//---------------------------------------------------------------------------------
-----
texture2D texColor;

//---------------------------------------------------------------------------------
-----
// Sampler Inputs
//---------------------------------------------------------------------------------
-----

sampler2D InputSampler = sampler_state


{
Texture = (texColor);
MinFilter = Point;
MagFilter = Anisotropic;
MipFilter = Point;
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;
};

float pixelWidth;
float pixelHeight;

//---------------------------------------------------------------------------------
-----
// Vertex Shader Input
//---------------------------------------------------------------------------------
-----

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;
}

//---------------------------------------------------------------------------------
-----
// Pixel Shader
//---------------------------------------------------------------------------------
-----

float4 main(float2 uv : TEXCOORD) : COLOR


{
float4 c = tex2D(InputSampler, uv);

c.rgb = max(0, c.rgb - Defog * FogColor.rgb);


c.rgb *= pow(2.0f, Exposure);
c.rgb = pow(c.rgb, Gamma);

float3 d = c.rgb * float3(1.05f, 0.97f, 1.27f);


c.rgb = lerp(c.rgb, d, BlueShift);

float2 InputSize = float2(sxres, syres/aspect);


float Amount = sharps;
float2 offset = offsetv / InputSize;
float4 color;
color = tex2D(InputSampler, uv);
color += tex2D(InputSampler, uv - offset) * Amount;
color -= tex2D(InputSampler, uv + offset) * Amount;

float middlegray=(c.r+c.g+c.b)*0.333;
float3 diffcolor=c.rgb-middlegray;
c.rgb+=diffcolor*-sat;

return c * color;
}

//---------------------------------------------------------------------------------
-----
// Compiler
//---------------------------------------------------------------------------------
-----
technique PostProcess
{
pass P0
{
#ifdef E_SHADER_3_0
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 main();
#else
VertexShader = compile vs_2_0 VS_PostProcess();
PixelShader = compile ps_2_0 main();
#endif

ZEnable=FALSE;
CullMode=NONE;
ALPHATESTENABLE=FALSE;
SEPARATEALPHABLENDENABLE=FALSE;
AlphaBlendEnable=FALSE;
FogEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}

You might also like