2 * Copyright (C) 2005-2015 Team Kodi
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 float4 pos : POSITION;
25 float2 tex : TEXCOORD0;
26 float2 tex2 : TEXCOORD1;
31 float4 pos : SV_POSITION;
33 float2 tex : TEXCOORD0;
34 float2 tex2 : TEXCOORD1;
37 SamplerState LinearSampler : register(s0)
39 Filter = MIN_MAG_MIP_LINEAR;
45 cbuffer cbWorld : register(b0)
47 float4x4 worldViewProj;
54 inline float3 transferPQ(float3 x)
56 static const float ST2084_m1 = 2610.0f / (4096.0f * 4.0f);
57 static const float ST2084_m2 = (2523.0f / 4096.0f) * 128.0f;
58 static const float ST2084_c1 = 3424.0f / 4096.0f;
59 static const float ST2084_c2 = (2413.0f / 4096.0f) * 32.0f;
60 static const float ST2084_c3 = (2392.0f / 4096.0f) * 32.0f;
61 static const float3x3 matx =
63 0.627402, 0.329292, 0.043306,
64 0.069095, 0.919544, 0.011360,
65 0.016394, 0.088028, 0.895578
68 x = pow(x, 1.0f / 0.45f);
72 x = pow(x / sdrPeakLum, ST2084_m1);
73 x = (ST2084_c1 + ST2084_c2 * x) / (1.0f + ST2084_c3 * x);
74 x = pow(x, ST2084_m2);
78 inline float4 tonemapHDR(float4 color)
80 return (PQ) ? float4(transferPQ(color.rgb), color.a) : color;
83 inline float4 adjustColorRange(float4 color)
85 return float4(blackLevel + colorRange * color.rgb, color.a);
88 #define STEREO_LEFT_EYE_INDEX 0
89 #define STEREO_RIGHT_EYE_INDEX 1
91 #ifdef STEREO_MODE_SHADER
93 inline float4 StereoInterlaced(PS_INPUT input, int eye)
95 uint pixelY = abs(trunc(input.tex.y * g_viewPortHeigh));
96 uint odd = pixelY % 2;
98 if ((odd == 0 && !eye) || (odd != 0 && eye))
99 return float4(texView.Sample(LinearSampler, input.tex).rgb, 1.0);
101 return float4(0.0, 0.0, 0.0, 0.0);
104 inline float4 StereoCheckerboard(PS_INPUT input, int eye)
106 uint pixelX = abs(trunc(input.tex.x * g_viewPortWidth));
107 uint pixelY = abs(trunc(input.tex.y * g_viewPortHeigh));
108 uint odd = (pixelX + pixelY) % 2;
110 if ((odd == 0 && !eye) || (odd != 0 && eye))
111 return float4(texView.Sample(LinearSampler, input.tex).rgb, 1.0);
113 return float4(0.0, 0.0, 0.0, 0.0);