Compute row location using gl_FragCoord.

This commit is contained in:
Christopher Bruns 2016-10-02 13:11:07 -04:00
parent 460b653709
commit fcbf9342d6
4 changed files with 9 additions and 12 deletions

View file

@ -54,6 +54,7 @@ void FPresent3DRowShader::Bind()
Contrast.Init(mShader, "Contrast");
Brightness.Init(mShader, "Brightness");
Scale.Init(mShader, "UVScale");
WindowHeight.Init(mShader, "WindowHeight");
VerticalPixelOffset.Init(mShader, "VerticalPixelOffset");
}
mShader.Bind();

View file

@ -41,6 +41,7 @@ public:
FBufferedUniform1f Contrast;
FBufferedUniform1f Brightness;
FBufferedUniform2f Scale;
FBufferedUniform1i WindowHeight;
FBufferedUniform1i VerticalPixelOffset;
private:

View file

@ -61,14 +61,6 @@ void RowInterleaved3D::Present() const
GLRenderer->mBuffers->BindOutputFB();
GLRenderer->ClearBorders();
// Compute screen regions to use for left and right eye views
int topHeight = GLRenderer->mOutputLetterbox.height / 2;
GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox;
topHalfScreen.height = topHeight;
topHalfScreen.top = topHeight;
GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox;
bottomHalfScreen.height = topHeight;
bottomHalfScreen.top = 0;
// Bind each eye texture, for composition in the shader
GLRenderer->mBuffers->BindEyeTexture(0, 0);
@ -90,6 +82,7 @@ void RowInterleaved3D::Present() const
GLRenderer->mPresent3dRowShader->Bind();
GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0);
GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1);
if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive())
{
GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f);
@ -105,7 +98,11 @@ void RowInterleaved3D::Present() const
GLRenderer->mPresent3dRowShader->Scale.Set(
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight());
GLRenderer->mPresent3dRowShader->WindowHeight.Set(0);
GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location
GLRenderer->RenderScreenQuad();
}

View file

@ -7,6 +7,7 @@ uniform sampler2D RightEyeTexture;
uniform float InvGamma;
uniform float Contrast;
uniform float Brightness;
uniform int WindowHeight;
uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen
vec4 ApplyGamma(vec4 c)
@ -19,10 +20,7 @@ vec4 ApplyGamma(vec4 c)
void main()
{
// NOTE we assume here that the full screen height is the sum of the left
// and right eye view heights
int screenHeightInPixels = textureSize(LeftEyeTexture, 0).y + textureSize(RightEyeTexture, 0).y;
int thisVerticalPixel = int(TexCoord.y * screenHeightInPixels + 0.5);
int thisVerticalPixel = int(gl_FragCoord.y);
bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0;
vec4 inputColor;
if (isLeftEye) {