Fix passthrough shader

It was not using half coordinate center
This commit is contained in:
Vincent Lejeune 2015-02-23 22:02:32 +01:00
parent 65cb55add4
commit 06f0188a5b
8 changed files with 27 additions and 24 deletions

View File

@ -0,0 +1,11 @@
uniform sampler2D tex;
uniform int width;
uniform int height;
out vec4 FragColor;
void main()
{
vec2 uv = gl_FragCoord.xy / vec2(width, height);
FragColor = texture(tex, uv);
}

View File

@ -468,15 +468,10 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
}
void PostProcessing::renderPassThrough(GLuint tex)
void PostProcessing::renderPassThrough(GLuint tex, unsigned width, unsigned height)
{
glUseProgram(FullScreenShader::PassThroughShader::getInstance()->Program);
glBindVertexArray(FullScreenShader::PassThroughShader::getInstance()->vao);
FullScreenShader::PassThroughShader::getInstance()->SetTextureUnits(tex);
FullScreenShader::PassThroughShader::getInstance()->setUniforms();
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
DrawFullScreenEffect<FullScreenShader::PassThroughShader>(width, height);
}
void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer)
@ -728,7 +723,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
glBlendEquation(GL_FUNC_ADD);
in_fbo->Bind();
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2), in_fbo->getWidth(), in_fbo->getHeight());
glDisable(GL_BLEND);
}
PROFILER_POP_CPU_MARKER();
@ -762,17 +757,17 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_128), irr_driver->getFBO(FBO_TMP_128), 1., 1.);
glEnable(GL_BLEND);
irr_driver->getFBO(FBO_BLOOM_256).Bind();
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_128).getRTT()[0]);
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_128).getRTT()[0], 256, 256);
glDisable(GL_BLEND);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_256), irr_driver->getFBO(FBO_TMP_256), 2., 2.);
glEnable(GL_BLEND);
irr_driver->getFBO(FBO_BLOOM_512).Bind();
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_256).getRTT()[0]);
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_256).getRTT()[0], 512, 512);
glDisable(GL_BLEND);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_512), irr_driver->getFBO(FBO_TMP_512), 2., 2.);
glEnable(GL_BLEND);
irr_driver->getFBO(FBO_BLOOM_1024).Bind();
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_512).getRTT()[0]);
renderPassThrough(irr_driver->getFBO(FBO_BLOOM_512).getRTT()[0], 1024, 1024);
glDisable(GL_BLEND);
renderGaussian6Blur(irr_driver->getFBO(FBO_BLOOM_1024), irr_driver->getFBO(FBO_TMP_1024), 2., 2.);
@ -828,7 +823,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
glEnable(GL_FRAMEBUFFER_SRGB);
irr_driver->getFBO(FBO_MLAA_COLORS).Bind();
renderPassThrough(in_fbo->getRTT()[0]);
renderPassThrough(in_fbo->getRTT()[0], irr_driver->getFBO(FBO_MLAA_COLORS).getWidth(), irr_driver->getFBO(FBO_MLAA_COLORS).getHeight());
out_fbo = &irr_driver->getFBO(FBO_MLAA_COLORS);
if (UserConfigParams::m_mlaa) // MLAA. Must be the last pp filter.

View File

@ -91,7 +91,7 @@ public:
void renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &auxiliary);
/** Render tex. Used for blit/texture resize */
void renderPassThrough(unsigned tex);
void renderPassThrough(unsigned tex, unsigned width, unsigned height);
void renderTextureLayer(unsigned tex, unsigned layer);
void applyMLAA();

View File

@ -254,13 +254,13 @@ void IrrDriver::renderGLSL(float dt)
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
m_post_processing->renderPassThrough(m_rtts->getFBO(FBO_HALF1_R).getRTT()[0]);
m_post_processing->renderPassThrough(m_rtts->getFBO(FBO_HALF1_R).getRTT()[0], viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
}
else if (irr_driver->getRSM())
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
m_post_processing->renderPassThrough(m_rtts->getRSM().getRTT()[0]);
m_post_processing->renderPassThrough(m_rtts->getRSM().getRTT()[0], viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
}
else if (irr_driver->getShadowViz())
{
@ -272,7 +272,7 @@ void IrrDriver::renderGLSL(float dt)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (CVS->isDefferedEnabled())
camera->activate();
m_post_processing->renderPassThrough(fbo->getRTT()[0]);
m_post_processing->renderPassThrough(fbo->getRTT()[0], viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
glDisable(GL_FRAMEBUFFER_SRGB);
}
}

View File

@ -883,7 +883,7 @@ void IrrDriver::renderTransparent()
irr_driver->getFBO(FBO_COLORS).Bind();
glStencilFunc(GL_EQUAL, 1, 0xFF);
m_post_processing->renderPassThrough(m_rtts->getRenderTarget(RTT_DISPLACE));
m_post_processing->renderPassThrough(m_rtts->getRenderTarget(RTT_DISPLACE), irr_driver->getFBO(FBO_COLORS).getWidth(), irr_driver->getFBO(FBO_COLORS).getHeight());
glDisable(GL_STENCIL_TEST);
}

View File

@ -289,5 +289,5 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
getFBO(FBO_COLORS).Bind();
m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1));
m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1), getFBO(FBO_COLORS).getWidth(), getFBO(FBO_COLORS).getHeight());
}

View File

@ -1875,11 +1875,10 @@ namespace FullScreenShader
{
Program = LoadProgram(OBJECT,
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/texturedquad.frag").c_str());
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/passthrough.frag").c_str());
AssignUniforms();
AssignUniforms("width", "height");
AssignSamplerNames(Program, 0, "tex");
vao = createVAO(Program);
}
LayerPassThroughShader::LayerPassThroughShader()

View File

@ -557,11 +557,9 @@ public:
Gaussian3VBlurShader();
};
class PassThroughShader : public ShaderHelperSingleton<PassThroughShader>, public TextureRead<Bilinear_Filtered>
class PassThroughShader : public ShaderHelperSingleton<PassThroughShader, int, int>, public TextureRead<Bilinear_Filtered>
{
public:
GLuint vao;
PassThroughShader();
};