utkuatlastuzcu/tst / Engine /Shaders /TdCalibrationShader.usf
utkuatlastuzcu's picture
download
raw
4.13 kB
#include "Common.usf"
#if !XBOX
sampler1D ColorCurvesKTexture;
sampler1D ColorCurvesMTexture;
#endif
float4 GammaColorScaleAndInverse;
float4 GammaOverlayColor;
static float3 GammaColorScale = GammaColorScaleAndInverse.rgb;
static float GammaInverse = GammaColorScaleAndInverse.a;
#define NUM_CURVE_SEGMENTS 16
float3 Ms[NUM_CURVE_SEGMENTS];
float3 Bs[NUM_CURVE_SEGMENTS];
half4 SceneCoordinateScaleBias;
/**
* pass through the screenspace position/UV
*/
void MainVertexShader(
in float4 InPosition : POSITION,
in float2 InTexCoord : TEXCOORD0,
in float2 InTexCoord2 : TEXCOORD1,
out float4 OutPosition : POSITION,
out float2 OutSceneTexCoord : TEXCOORD0,
out float2 OutScreenPosTexCoord : TEXCOORD1
)
{
OutPosition = float4(InPosition.rg,0,1);
OutSceneTexCoord = InTexCoord.xy * SceneCoordinateScaleBias.xy + SceneCoordinateScaleBias.wz;
OutScreenPosTexCoord = InTexCoord2;
}
void MainPixelShader(
in float4 Pos : POSITION,
in float2 SceneTexCoord : TEXCOORD0,
in float2 ScreenPosTexCoord : TEXCOORD1,
out float4 OutColor : COLOR0
)
{
half3 Color = tex2D(SceneColorTexture,SceneTexCoord).rgb;
half3 MaterialResult = Color;
float isQuad = 0.0f;
#if XBOX || PS3
if(ScreenPosTexCoord.x > 0.65 && ScreenPosTexCoord.x < 0.85 && ScreenPosTexCoord.y > 0.35 && ScreenPosTexCoord.y < 0.57)
{
if(ScreenPosTexCoord.x > 0.7 && ScreenPosTexCoord.x < 0.8 && ScreenPosTexCoord.y > 0.4 && ScreenPosTexCoord.y < 0.52)
{
MaterialResult.rgb = float3(0.95f,0.95f,0.95f);
}
else
{
MaterialResult.rgb = float3(1,1,1);
}
isQuad = 1.0f;
}
if(ScreenPosTexCoord.x > 0.65 && ScreenPosTexCoord.x < 0.85 && ScreenPosTexCoord.y > 0.605 && ScreenPosTexCoord.y < 0.8375)
{
if(ScreenPosTexCoord.x > 0.7 && ScreenPosTexCoord.x < 0.8 && ScreenPosTexCoord.y > 0.655 && ScreenPosTexCoord.y < 0.7875)
{
MaterialResult.rgb = float3(0.005f,0.005f,0.005f);
}
else
{
MaterialResult.rgb = float3(0,0,0);
}
isQuad = 1.0f;
}
#else
if(ScreenPosTexCoord.x > 0.65 && ScreenPosTexCoord.x < 0.85 && ScreenPosTexCoord.y > 0.35 && ScreenPosTexCoord.y < 0.574)
{
if(ScreenPosTexCoord.x > 0.7 && ScreenPosTexCoord.x < 0.8 && ScreenPosTexCoord.y > 0.4 && ScreenPosTexCoord.y < 0.524)
{
MaterialResult.rgb = float3(0.95f,0.95f,0.95f);
}
else
{
MaterialResult.rgb = float3(1,1,1);
}
isQuad = 1.0f;
}
if(ScreenPosTexCoord.x > 0.65 && ScreenPosTexCoord.x < 0.85 && ScreenPosTexCoord.y > 0.605 && ScreenPosTexCoord.y < 0.8375)
{
if(ScreenPosTexCoord.x > 0.7 && ScreenPosTexCoord.x < 0.8 && ScreenPosTexCoord.y > 0.655 && ScreenPosTexCoord.y < 0.7875)
{
MaterialResult.rgb = float3(0.005f,0.005f,0.005f);
}
else
{
MaterialResult.rgb = float3(0,0,0);
}
isQuad = 1.0f;
}
#endif
OutColor.rgb = pow(saturate(MaterialResult.rgb * GammaColorScale.rgb), GammaInverse);
#if XBOX
int SegmentR = trunc(OutColor.r*(NUM_CURVE_SEGMENTS-1));
SegmentR = clamp(SegmentR,0,NUM_CURVE_SEGMENTS-2);
OutColor.r = OutColor.r*Ms[SegmentR].r+Bs[SegmentR].r;
int SegmentG = trunc(OutColor.g*(NUM_CURVE_SEGMENTS-1));
SegmentG = clamp(SegmentG,0,NUM_CURVE_SEGMENTS-2);
OutColor.g = OutColor.g*Ms[SegmentG].g+Bs[SegmentG].g;
int SegmentB = trunc(OutColor.b*(NUM_CURVE_SEGMENTS-1));
SegmentB = clamp(SegmentB,0,NUM_CURVE_SEGMENTS-2);
OutColor.b = OutColor.b*Ms[SegmentB].b+Bs[SegmentB].b;
#else
float Correction = 15.0f/16.0f;
float4 rCurve = tex1D(ColorCurvesKTexture, saturate(OutColor.r*Correction)); //Ktex.r = Curves
float4 gCurve = tex1D(ColorCurvesKTexture, saturate(OutColor.g*Correction));
float4 bCurve = tex1D(ColorCurvesMTexture, saturate(OutColor.b*Correction));
OutColor.r = OutColor.r*rCurve.r + rCurve.g; //KTexture.r = Ms.r KTexture.g = Bs.r
OutColor.g = OutColor.g*gCurve.b + gCurve.a; //KTexture.b = Ms.g KTexture.a = Bs.g
OutColor.b = OutColor.b*bCurve.r + bCurve.g; //MTexture.r = Ms.b MTexture.g = Bs.b
#endif
OutColor.rgb = lerp(Color, OutColor.rgb, isQuad);
OutColor.a = 1;
}

Xet Storage Details

Size:
4.13 kB
·
Xet hash:
24d0c77a0bdaf132e1ea8d6d7b9567a2b5335f58408c56393d75d7f52b7763cd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.