Port gaussianV shaders
This commit is contained in:
parent
be52d07418
commit
d8e4a352ba
@ -322,16 +322,13 @@ void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::vao);
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::getInstance()->vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian3VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian3VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian3VBlurShader::uniform_tex, 0);
|
||||
|
||||
FullScreenShader::Gaussian3VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
{
|
||||
@ -354,15 +351,13 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::vao);
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::getInstance()->vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian6VBlurShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian6VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian6VBlurShader::uniform_tex, 0);
|
||||
FullScreenShader::Gaussian6VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
@ -422,32 +417,27 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
#endif
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapVShader::Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapVShader::vao);
|
||||
glUseProgram(FullScreenShader::Gaussian17TapVShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapVShader::getInstance()->vao);
|
||||
|
||||
glUniform2f(FullScreenShader::Gaussian17TapVShader::uniform_pixel, inv_width, inv_height);
|
||||
|
||||
setTexture(0, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
setTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_tex, 0);
|
||||
glUniform1i(FullScreenShader::Gaussian17TapVShader::uniform_depth, 1);
|
||||
FullScreenShader::Gaussian17TapVShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
{
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::Program);
|
||||
glBindImageTexture(0, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(1, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(2, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_source, 0);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_depth, 1);
|
||||
glUniform1i(FullScreenShader::ComputeGaussian17TapVShader::uniform_dest, 2);
|
||||
glUseProgram(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->Program);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_tex, auxiliary.getRTT()[0], 0, false, 0, GL_READ_ONLY, GL_R16F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], 1, false, 0, GL_READ_ONLY, GL_R32F);
|
||||
glBindImageTexture(FullScreenShader::ComputeGaussian17TapVShader::getInstance()->TU_dest, in_fbo.getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R16F);
|
||||
FullScreenShader::ComputeGaussian17TapVShader::getInstance()->setUniforms();
|
||||
glDispatchCompute(in_fbo.getWidth() / 8, in_fbo.getHeight() / 8, 1);
|
||||
}
|
||||
#endif
|
||||
|
@ -375,10 +375,6 @@ void Shaders::loadShaders()
|
||||
initShadowVPMUBO();
|
||||
FullScreenShader::BloomBlendShader::init();
|
||||
FullScreenShader::BloomShader::init();
|
||||
FullScreenShader::Gaussian3VBlurShader::init();
|
||||
FullScreenShader::Gaussian17TapVShader::init();
|
||||
FullScreenShader::ComputeGaussian17TapVShader::init();
|
||||
FullScreenShader::Gaussian6VBlurShader::init();
|
||||
FullScreenShader::GlowShader::init();
|
||||
FullScreenShader::PassThroughShader::init();
|
||||
FullScreenShader::LayerPassThroughShader::init();
|
||||
@ -1815,64 +1811,51 @@ namespace FullScreenShader
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GLuint Gaussian17TapVShader::Program;
|
||||
GLuint Gaussian17TapVShader::uniform_tex;
|
||||
GLuint Gaussian17TapVShader::uniform_depth;
|
||||
GLuint Gaussian17TapVShader::uniform_pixel;
|
||||
GLuint Gaussian17TapVShader::vao;
|
||||
void Gaussian17TapVShader::init()
|
||||
Gaussian17TapVShader::Gaussian17TapVShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bilateralV.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "depth"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GLuint ComputeGaussian17TapVShader::Program;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_source;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_depth;
|
||||
GLuint ComputeGaussian17TapVShader::uniform_dest;
|
||||
void ComputeGaussian17TapVShader::init()
|
||||
ComputeGaussian17TapVShader::ComputeGaussian17TapVShader()
|
||||
{
|
||||
#if WIN32
|
||||
if (irr_driver->getGLSLVersion() < 420)
|
||||
return;
|
||||
Program = LoadProgram(
|
||||
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/bilateralV.comp").c_str());
|
||||
uniform_source = glGetUniformLocation(Program, "source");
|
||||
uniform_depth = glGetUniformLocation(Program, "depth");
|
||||
uniform_dest = glGetUniformLocation(Program, "dest");
|
||||
TU_source = 0;
|
||||
TU_depth = 1;
|
||||
TU_dest = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_source, "source"), TexUnit(TU_depth, "depth"), TexUnit(TU_dest, "dest"));
|
||||
#endif
|
||||
}
|
||||
|
||||
GLuint Gaussian6VBlurShader::Program;
|
||||
GLuint Gaussian6VBlurShader::uniform_tex;
|
||||
GLuint Gaussian6VBlurShader::uniform_pixel;
|
||||
GLuint Gaussian6VBlurShader::vao;
|
||||
void Gaussian6VBlurShader::init()
|
||||
Gaussian6VBlurShader::Gaussian6VBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian6v.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GLuint Gaussian3VBlurShader::Program;
|
||||
GLuint Gaussian3VBlurShader::uniform_tex;
|
||||
GLuint Gaussian3VBlurShader::uniform_pixel;
|
||||
GLuint Gaussian3VBlurShader::vao;
|
||||
void Gaussian3VBlurShader::init()
|
||||
Gaussian3VBlurShader::Gaussian3VBlurShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/gaussian3v.frag").c_str());
|
||||
uniform_tex = glGetUniformLocation(Program, "tex");
|
||||
uniform_pixel = glGetUniformLocation(Program, "pixel");
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
|
@ -650,44 +650,40 @@ public:
|
||||
Gaussian3HBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian17TapVShader
|
||||
class Gaussian17TapVShader : public ShaderHelperSingleton<Gaussian17TapVShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_depth, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
Gaussian17TapVShader();
|
||||
};
|
||||
|
||||
class ComputeGaussian17TapVShader
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_source, uniform_depth, uniform_dest;
|
||||
GLuint TU_source, TU_depth, TU_dest;
|
||||
|
||||
static void init();
|
||||
ComputeGaussian17TapVShader();
|
||||
};
|
||||
|
||||
|
||||
class Gaussian6VBlurShader
|
||||
class Gaussian6VBlurShader : public ShaderHelperSingleton<Gaussian6VBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
Gaussian6VBlurShader();
|
||||
};
|
||||
|
||||
class Gaussian3VBlurShader
|
||||
class Gaussian3VBlurShader : public ShaderHelperSingleton<Gaussian3VBlurShader, core::vector2df>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_pixel;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
Gaussian3VBlurShader();
|
||||
};
|
||||
|
||||
class PassThroughShader
|
||||
|
Loading…
Reference in New Issue
Block a user