2016-10-09 17:05:50 +00:00
|
|
|
|
2019-03-05 17:55:31 +00:00
|
|
|
layout(location=0) in vec2 TexCoord;
|
2018-06-12 21:52:33 +00:00
|
|
|
layout(location=0) out vec4 FragColor;
|
2016-10-09 17:05:50 +00:00
|
|
|
|
2018-06-13 13:53:56 +00:00
|
|
|
layout(binding=0) uniform sampler2D LeftEyeTexture;
|
|
|
|
layout(binding=1) uniform sampler2D RightEyeTexture;
|
2016-10-09 17:05:50 +00:00
|
|
|
|
|
|
|
vec4 ApplyGamma(vec4 c)
|
|
|
|
{
|
|
|
|
vec3 val = c.rgb * Contrast - (Contrast - 1.0) * 0.5;
|
|
|
|
val += Brightness * 0.5;
|
|
|
|
val = pow(max(val, vec3(0.0)), vec3(InvGamma));
|
|
|
|
return vec4(val, c.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
int thisHorizontalPixel = int(gl_FragCoord.x); // zero-based column index from left
|
|
|
|
bool isLeftEye = (thisHorizontalPixel // because we want to alternate eye view on each column
|
|
|
|
+ WindowPositionParity // because the window might not be aligned to the screen
|
|
|
|
) % 2 == 0;
|
|
|
|
vec4 inputColor;
|
|
|
|
if (isLeftEye) {
|
2019-03-12 22:53:20 +00:00
|
|
|
inputColor = texture(LeftEyeTexture, UVOffset + TexCoord * UVScale);
|
2016-10-09 17:05:50 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// inputColor = vec4(0, 1, 0, 1);
|
2019-03-12 22:53:20 +00:00
|
|
|
inputColor = texture(RightEyeTexture, UVOffset + TexCoord * UVScale);
|
2016-10-09 17:05:50 +00:00
|
|
|
}
|
|
|
|
FragColor = ApplyGamma(inputColor);
|
|
|
|
}
|