diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp index fd7a6c4c6..225f52819 100644 --- a/src/gl/stereo3d/gl_interleaved3d.cpp +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -99,7 +99,10 @@ void RowInterleaved3D::Present() const GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(), GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight()); - GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location + GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set( + 0 // fixme: vary with window location + + box.height % 2 // because we want the top pixel offset, but gl_FragCoord.y is the bottom pixel offset + ); GLRenderer->RenderScreenQuad(); } diff --git a/wadsrc/static/shaders/glsl/present_row3d.fp b/wadsrc/static/shaders/glsl/present_row3d.fp index 73a01539b..8ae72d1e0 100644 --- a/wadsrc/static/shaders/glsl/present_row3d.fp +++ b/wadsrc/static/shaders/glsl/present_row3d.fp @@ -7,7 +7,6 @@ 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) @@ -20,8 +19,10 @@ vec4 ApplyGamma(vec4 c) void main() { - int thisVerticalPixel = int(gl_FragCoord.y); - bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0; + int thisVerticalPixel = int(gl_FragCoord.y + 1.0); // Bottom row is typically the right eye, when WindowHeight is even + bool isLeftEye = (thisVerticalPixel // because we want to alternate eye view on each row + + VerticalPixelOffset // because the window might not be aligned to the screen + ) % 2 == 0; vec4 inputColor; if (isLeftEye) { inputColor = texture(LeftEyeTexture, TexCoord);