mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-01-31 18:50:33 +00:00
Compute row location using gl_FragCoord.
This commit is contained in:
parent
460b653709
commit
fcbf9342d6
4 changed files with 9 additions and 12 deletions
|
@ -54,6 +54,7 @@ void FPresent3DRowShader::Bind()
|
||||||
Contrast.Init(mShader, "Contrast");
|
Contrast.Init(mShader, "Contrast");
|
||||||
Brightness.Init(mShader, "Brightness");
|
Brightness.Init(mShader, "Brightness");
|
||||||
Scale.Init(mShader, "UVScale");
|
Scale.Init(mShader, "UVScale");
|
||||||
|
WindowHeight.Init(mShader, "WindowHeight");
|
||||||
VerticalPixelOffset.Init(mShader, "VerticalPixelOffset");
|
VerticalPixelOffset.Init(mShader, "VerticalPixelOffset");
|
||||||
}
|
}
|
||||||
mShader.Bind();
|
mShader.Bind();
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
FBufferedUniform1f Contrast;
|
FBufferedUniform1f Contrast;
|
||||||
FBufferedUniform1f Brightness;
|
FBufferedUniform1f Brightness;
|
||||||
FBufferedUniform2f Scale;
|
FBufferedUniform2f Scale;
|
||||||
|
FBufferedUniform1i WindowHeight;
|
||||||
FBufferedUniform1i VerticalPixelOffset;
|
FBufferedUniform1i VerticalPixelOffset;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -61,14 +61,6 @@ void RowInterleaved3D::Present() const
|
||||||
GLRenderer->mBuffers->BindOutputFB();
|
GLRenderer->mBuffers->BindOutputFB();
|
||||||
GLRenderer->ClearBorders();
|
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
|
// Bind each eye texture, for composition in the shader
|
||||||
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
||||||
|
@ -90,6 +82,7 @@ void RowInterleaved3D::Present() const
|
||||||
GLRenderer->mPresent3dRowShader->Bind();
|
GLRenderer->mPresent3dRowShader->Bind();
|
||||||
GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0);
|
GLRenderer->mPresent3dRowShader->LeftEyeTexture.Set(0);
|
||||||
GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1);
|
GLRenderer->mPresent3dRowShader->RightEyeTexture.Set(1);
|
||||||
|
|
||||||
if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive())
|
if (!applyGamma || GLRenderer->framebuffer->IsHWGammaActive())
|
||||||
{
|
{
|
||||||
GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f);
|
GLRenderer->mPresent3dRowShader->InvGamma.Set(1.0f);
|
||||||
|
@ -105,7 +98,11 @@ void RowInterleaved3D::Present() const
|
||||||
GLRenderer->mPresent3dRowShader->Scale.Set(
|
GLRenderer->mPresent3dRowShader->Scale.Set(
|
||||||
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
GLRenderer->mScreenViewport.width / (float)GLRenderer->mBuffers->GetWidth(),
|
||||||
GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight());
|
GLRenderer->mScreenViewport.height / (float)GLRenderer->mBuffers->GetHeight());
|
||||||
|
|
||||||
|
GLRenderer->mPresent3dRowShader->WindowHeight.Set(0);
|
||||||
|
|
||||||
GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location
|
GLRenderer->mPresent3dRowShader->VerticalPixelOffset.Set(0); // fixme: vary with window location
|
||||||
|
|
||||||
GLRenderer->RenderScreenQuad();
|
GLRenderer->RenderScreenQuad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ uniform sampler2D RightEyeTexture;
|
||||||
uniform float InvGamma;
|
uniform float InvGamma;
|
||||||
uniform float Contrast;
|
uniform float Contrast;
|
||||||
uniform float Brightness;
|
uniform float Brightness;
|
||||||
|
uniform int WindowHeight;
|
||||||
uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen
|
uniform int VerticalPixelOffset; // top-of-window might not be top-of-screen
|
||||||
|
|
||||||
vec4 ApplyGamma(vec4 c)
|
vec4 ApplyGamma(vec4 c)
|
||||||
|
@ -19,10 +20,7 @@ vec4 ApplyGamma(vec4 c)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// NOTE we assume here that the full screen height is the sum of the left
|
int thisVerticalPixel = int(gl_FragCoord.y);
|
||||||
// and right eye view heights
|
|
||||||
int screenHeightInPixels = textureSize(LeftEyeTexture, 0).y + textureSize(RightEyeTexture, 0).y;
|
|
||||||
int thisVerticalPixel = int(TexCoord.y * screenHeightInPixels + 0.5);
|
|
||||||
bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0;
|
bool isLeftEye = (thisVerticalPixel + VerticalPixelOffset) % 2 == 0;
|
||||||
vec4 inputColor;
|
vec4 inputColor;
|
||||||
if (isLeftEye) {
|
if (isLeftEye) {
|
||||||
|
|
Loading…
Reference in a new issue