Use direct call for Gaussian 6 Blur.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@15041 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9b4288b576
commit
62e5fbf6ad
@ -426,6 +426,64 @@ namespace LightBlendShader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Gaussian6HBlurShader
|
||||||
|
{
|
||||||
|
GLuint Program = 0;
|
||||||
|
GLuint attrib_position, attrib_texcoord;
|
||||||
|
GLuint uniform_tex, uniform_pixel;
|
||||||
|
|
||||||
|
GLuint vao = 0;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
initGL();
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/gaussian6h.frag").c_str());
|
||||||
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
|
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||||
|
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||||
|
if (!quad_vbo)
|
||||||
|
initQuadVBO();
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
||||||
|
glEnableVertexAttribArray(attrib_position);
|
||||||
|
glEnableVertexAttribArray(attrib_texcoord);
|
||||||
|
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
|
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float)));
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Gaussian6VBlurShader
|
||||||
|
{
|
||||||
|
GLuint Program = 0;
|
||||||
|
GLuint attrib_position, attrib_texcoord;
|
||||||
|
GLuint uniform_tex, uniform_pixel;
|
||||||
|
|
||||||
|
GLuint vao = 0;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
initGL();
|
||||||
|
Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/gaussian6v.frag").c_str());
|
||||||
|
attrib_position = glGetAttribLocation(Program, "Position");
|
||||||
|
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
|
||||||
|
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||||
|
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||||
|
if (!quad_vbo)
|
||||||
|
initQuadVBO();
|
||||||
|
glGenVertexArrays(1, &vao);
|
||||||
|
glBindVertexArray(vao);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, quad_vbo);
|
||||||
|
glEnableVertexAttribArray(attrib_position);
|
||||||
|
glEnableVertexAttribArray(attrib_texcoord);
|
||||||
|
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
|
||||||
|
glVertexAttribPointer(attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid*)(2 * sizeof(float)));
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void renderBloom(ITexture *in)
|
void renderBloom(ITexture *in)
|
||||||
@ -605,6 +663,46 @@ void PostProcessing::renderLightbBlend(ITexture *diffuse, ITexture *specular, IT
|
|||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PostProcessing::renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height)
|
||||||
|
{
|
||||||
|
glDisable(GL_BLEND);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
{
|
||||||
|
if (!Gaussian6VBlurShader::Program)
|
||||||
|
Gaussian6VBlurShader::init();
|
||||||
|
irr_driver->getVideoDriver()->setRenderTarget(temprtt, false, false);
|
||||||
|
glUseProgram(Gaussian6VBlurShader::Program);
|
||||||
|
glBindVertexArray(Gaussian6VBlurShader::vao);
|
||||||
|
|
||||||
|
glUniform2f(Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(in)->getOpenGLTextureName());
|
||||||
|
glUniform1i(Gaussian6VBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if (!Gaussian6HBlurShader::Program)
|
||||||
|
Gaussian6HBlurShader::init();
|
||||||
|
irr_driver->getVideoDriver()->setRenderTarget(in, false, false);
|
||||||
|
glUseProgram(Gaussian6HBlurShader::Program);
|
||||||
|
glBindVertexArray(Gaussian6HBlurShader::vao);
|
||||||
|
|
||||||
|
glUniform2f(Gaussian6HBlurShader::uniform_pixel, inv_width, inv_height);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, static_cast<irr::video::COpenGLTexture*>(temprtt)->getOpenGLTextureName());
|
||||||
|
glUniform1i(Gaussian6HBlurShader::uniform_tex, 0);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
}
|
||||||
|
glBindVertexArray(0);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Render the post-processed scene */
|
/** Render the post-processed scene */
|
||||||
void PostProcessing::render()
|
void PostProcessing::render()
|
||||||
@ -776,25 +874,14 @@ void PostProcessing::render()
|
|||||||
drawQuad(cam, m_material);
|
drawQuad(cam, m_material);
|
||||||
|
|
||||||
// Blur it for distribution.
|
// Blur it for distribution.
|
||||||
{
|
renderGaussian6Blur(irr_driver->getRTT(RTT_EIGHTH1), irr_driver->getRTT(RTT_EIGHTH2), 8.f / UserConfigParams::m_width, 8.f / UserConfigParams::m_height);
|
||||||
gacb->setResolution(UserConfigParams::m_width / 8,
|
|
||||||
UserConfigParams::m_height / 8);
|
|
||||||
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6V);
|
|
||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_EIGHTH1));
|
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH2), true, false);
|
|
||||||
|
|
||||||
drawQuad(cam, m_material);
|
|
||||||
|
|
||||||
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6H);
|
|
||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_EIGHTH2));
|
|
||||||
drv->setRenderTarget(irr_driver->getRTT(RTT_EIGHTH1), false, false);
|
|
||||||
|
|
||||||
drawQuad(cam, m_material);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Additively blend on top of tmp1
|
// Additively blend on top of tmp1
|
||||||
drv->setRenderTarget(out, false, false);
|
drv->setRenderTarget(out, false, false);
|
||||||
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
renderBloomBlend(irr_driver->getRTT(RTT_EIGHTH1));
|
||||||
|
m_material.MaterialType = irr_driver->getShader(ES_RAIN);
|
||||||
|
drv->setMaterial(m_material);
|
||||||
|
static_cast<irr::video::COpenGLDriver*>(drv)->setRenderStates3DMode();
|
||||||
} // end if bloom
|
} // end if bloom
|
||||||
|
|
||||||
in = irr_driver->getRTT(RTT_TMP1);
|
in = irr_driver->getRTT(RTT_TMP1);
|
||||||
|
@ -81,6 +81,9 @@ public:
|
|||||||
/** Blend all light related map */
|
/** Blend all light related map */
|
||||||
void renderLightbBlend(video::ITexture *diffuse, video::ITexture *specular, video::ITexture *ao, video::ITexture *specmap, bool debug);
|
void renderLightbBlend(video::ITexture *diffuse, video::ITexture *specular, video::ITexture *ao, video::ITexture *specmap, bool debug);
|
||||||
|
|
||||||
|
/** Blur the in texture */
|
||||||
|
void renderGaussian6Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height);
|
||||||
|
|
||||||
/** Render the post-processed scene */
|
/** Render the post-processed scene */
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
@ -794,19 +794,8 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
|
|||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_QUARTER4));
|
m_material.setTexture(0, irr_driver->getRTT(RTT_QUARTER4));
|
||||||
m_video_driver->setRenderTarget(irr_driver->getRTT(RTT_SSAO), false, false);
|
m_video_driver->setRenderTarget(irr_driver->getRTT(RTT_SSAO), false, false);
|
||||||
m_post_processing->drawQuad(cam, m_material);
|
m_post_processing->drawQuad(cam, m_material);
|
||||||
} else if (UserConfigParams::m_ssao == 2) {
|
} else if (UserConfigParams::m_ssao == 2)
|
||||||
gacb->setResolution(UserConfigParams::m_width,
|
m_post_processing->renderGaussian6Blur(irr_driver->getRTT(RTT_SSAO), irr_driver->getRTT(RTT_TMP4), 1.f / UserConfigParams::m_width, 1.f / UserConfigParams::m_height);
|
||||||
UserConfigParams::m_height);
|
|
||||||
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6V);
|
|
||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_SSAO));
|
|
||||||
m_video_driver->setRenderTarget(irr_driver->getRTT(RTT_TMP4), true, false);
|
|
||||||
m_post_processing->drawQuad(cam, m_material);
|
|
||||||
|
|
||||||
m_material.MaterialType = irr_driver->getShader(ES_GAUSSIAN6H);
|
|
||||||
m_material.setTexture(0, irr_driver->getRTT(RTT_TMP4));
|
|
||||||
m_video_driver->setRenderTarget(irr_driver->getRTT(RTT_SSAO), false, false);
|
|
||||||
m_post_processing->drawQuad(cam, m_material);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
m_video_driver->setRenderTarget(m_rtts->getRTT(RTT_COLOR), false, false);
|
||||||
if (!m_mipviz)
|
if (!m_mipviz)
|
||||||
|
Loading…
Reference in New Issue
Block a user