change blur to allow output to a different buffer then input

This commit is contained in:
Green Sky 2022-02-18 00:41:34 +01:00
parent 9ff0b17a5e
commit 7a461111e1
3 changed files with 13 additions and 10 deletions

View File

@ -48,12 +48,13 @@ Blur::~Blur(void) {
void Blur::render(Services::OpenGLRenderer& rs, Engine&) {
ZoneScopedN("MM::OpenGL::RenderTasks::Blur::render");
rs.targets[io_fbo]->bind(FrameBufferObject::W);
//rs.targets[io_fbo]->bind(FrameBufferObject::W);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND); // TODO: test
glDisable(GL_BLEND);
auto& rm_t = MM::ResourceManager<MM::OpenGL::Texture>::ref();
auto tex_io = rm_t.get(entt::hashed_string::value(io_tex.c_str())); // TODO: perf problems
auto tex_in = rm_t.get(entt::hashed_string::value(in_tex.c_str())); // TODO: perf problems
auto tex_out = rm_t.get(entt::hashed_string::value(out_tex.c_str())); // TODO: perf problems
auto tex_temp = rm_t.get(entt::hashed_string::value(temp_tex.c_str())); // TODO: perf problems
{ // horizontal
@ -64,7 +65,7 @@ void Blur::render(Services::OpenGLRenderer& rs, Engine&) {
_vao->bind();
glViewport(0, 0, tex_temp->width, tex_temp->height);
tex_io->bind(0); // read
tex_in->bind(0); // read
_hShader->setUniform2f("tex_offset", tex_offset);
@ -72,13 +73,13 @@ void Blur::render(Services::OpenGLRenderer& rs, Engine&) {
}
{ // vertical
rs.targets[io_fbo]->bind(FrameBufferObject::W);
rs.targets[out_fbo]->bind(FrameBufferObject::W);
_vShader->bind();
_vertexBuffer->bind(GL_ARRAY_BUFFER);
_vao->bind();
glViewport(0, 0, tex_io->width, tex_io->height);
glViewport(0, 0, tex_out->width, tex_out->height);
tex_temp->bind(0); // read
_vShader->setUniform2f("tex_offset", tex_offset);

View File

@ -35,11 +35,12 @@ namespace MM::OpenGL::RenderTasks {
const char* fragmentHPath = "shader/blur_render_task/frag_h.glsl";
const char* fragmentVPath = "shader/blur_render_task/frag_v.glsl";
std::string io_fbo = "blur_io";
std::string out_fbo = "blur_io";
std::string temp_fbo = "blur_temp";
// bc of it beeing a 2 pass, we need to flipflop
std::string io_tex = "blur_io";
std::string in_tex = "blur_io";
std::string out_tex = "blur_io";
std::string temp_tex = "blur_temp";
// determines the kernel lookup offset. "ideal" is 1/tex_size

View File

@ -72,9 +72,10 @@ TEST(blur_render_task, it) {
bsrr_rend.target_fbo = "blur_io";
MM::OpenGL::RenderTasks::Blur& blur_rend = rs.addRenderTask<MM::OpenGL::RenderTasks::Blur>(engine);
blur_rend.io_tex = "blur_io";
blur_rend.in_tex = "blur_io";
blur_rend.out_tex = "blur_io";
blur_rend.temp_tex = "blur_temp";
blur_rend.io_fbo = "blur_io";
blur_rend.out_fbo = "blur_io";
blur_rend.temp_fbo = "blur_temp";
// render to display