effect2
effect2
-----
// SAFE ( SA_For_Effect )
// Tonemaping, bloom & color correction
// Copyright 2014 (c) Buthen
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
// Defines
//---------------------------------------------------------------------------------
-----
#define COLOR_CORRECTION
#define TONEMAPPING_MODE_0
//---------------------------------------------------------------------------------
-----
// Vectors, floats and etc.
//---------------------------------------------------------------------------------
-----
float ScreenScaleY;
float ScreenSize;
float2 screenRes = {1920,1080};
//---------------------------------------------------------------------------------
-----
// Textures
//---------------------------------------------------------------------------------
-----
texture2D texColor;
texture2D texDepth;
texture2D texNoise;
//---------------------------------------------------------------------------------
-----
// Sampler Inputs
//---------------------------------------------------------------------------------
-----
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
//---------------------------------------------------------------------------------
-----
// Functions
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
// 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;
}
midtones.w = midtones.x;
midtones.x = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.x += midtones.w;
midtones.w = midtones.y;
midtones.y = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.y += midtones.w;
midtones.w = midtones.z;
midtones.z = (1 - midtones.w) - (factorM * ((1 - midtones.w) /
2));
midtones.z += midtones.w;
}
highlights.w = highlights.x;
highlights.x = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.x += highlights.w;
highlights.w = highlights.y;
highlights.y = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.y += highlights.w;
highlights.w = highlights.z;
highlights.z = (1 - highlights.w) - (factorM * ((1 -
highlights.w) / 2));
highlights.z += highlights.w;
}
//cie.r = lumScaled;
//color.rgb = FromCIE(cie);
return Color;
#endif
#ifdef TONEMAPPING_MODE_2
float A = 0.15;
float B = 0.50;
float C = 0.10;
float D = 0.20;
float E = 0.02;
float F = 0.30;
float W = 11.2;
Color *= _ExposureAdjustment;
x = W;
float3 whiteScale = 1.0f/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);
float3 clr = curr*whiteScale;
//cie.r = lumScaled;
//color.rgb = FromCIE(cie);
return Color;
#endif
#ifdef TONEMAPPING_MODE_OFF
return Color;
#endif
}
//---------------------------------------------------------------------------------
-----
// Compiler 1
//---------------------------------------------------------------------------------
-----
technique PostProcess
{
pass P0
{
VertexShader = compile vs_3_0 VS_PostProcess();
PixelShader = compile ps_3_0 CCShadow();
}
}