aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh
blob: 9886fc32bb828db76a37626c533bbe32b300acb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Texture2D Texture : register(t0);
Texture2D LastTexture : register(t1);
SamplerState Linear : register(s0);

float2 OverdriveInvRTSize;
float2 OverdriveScales;

void   main(in float4 oPosition  : SV_Position,
            in float1 oColor     : COLOR,
            in float2 oTexCoord0 : TEXCOORD0,
            in float2 oTexCoord1 : TEXCOORD1,
            in float2 oTexCoord2 : TEXCOORD2,
			out float4 outColor0 : SV_Target0,
			out float4 outColor1 : SV_Target1)
{
	float ResultR = Texture.SampleLevel(Linear, oTexCoord0, 0.0).r;
	float ResultG = Texture.SampleLevel(Linear, oTexCoord1, 0.0).g;
	float ResultB = Texture.SampleLevel(Linear, oTexCoord2, 0.0).b;
	float3 newColor = float3(ResultR * oColor, ResultG * oColor, ResultB * oColor);

	outColor0 = float4(newColor, 1.0);
	outColor1 = outColor0;

	// pixel luminance overdrive
	if(OverdriveInvRTSize.x > 0)
	{
		float3 oldColor = LastTexture.SampleLevel(Linear, oPosition.xy * OverdriveInvRTSize.xy, 0.0).rgb;
		
		float3 adjustedScales;
		adjustedScales.x = newColor.x > oldColor.x ? OverdriveScales.x : OverdriveScales.y;
		adjustedScales.y = newColor.y > oldColor.y ? OverdriveScales.x : OverdriveScales.y;
		adjustedScales.z = newColor.z > oldColor.z ? OverdriveScales.x : OverdriveScales.y;
		
		float3 overdriveColor = saturate(newColor + (newColor - oldColor) * adjustedScales);
		outColor1 = float4(overdriveColor, 1.0);
	}
}