Fix blur shader to use RenderScreenQuad

This commit is contained in:
Magnus Norddahl 2016-08-12 17:51:06 +02:00 committed by Christoph Oelckers
parent 210fce1193
commit 647ef5d029
3 changed files with 17 additions and 21 deletions

View file

@ -154,8 +154,8 @@ void FGLRenderer::BloomScene()
{ {
const auto &level = mBuffers->BloomLevels[i]; const auto &level = mBuffers->BloomLevels[i];
const auto &next = mBuffers->BloomLevels[i + 1]; const auto &next = mBuffers->BloomLevels[i + 1];
mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height);
mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height);
} }
// Blur and upscale: // Blur and upscale:
@ -164,8 +164,8 @@ void FGLRenderer::BloomScene()
const auto &level = mBuffers->BloomLevels[i]; const auto &level = mBuffers->BloomLevels[i];
const auto &next = mBuffers->BloomLevels[i - 1]; const auto &next = mBuffers->BloomLevels[i - 1];
mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height);
mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height);
// Linear upscale: // Linear upscale:
glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer);
@ -179,8 +179,8 @@ void FGLRenderer::BloomScene()
RenderScreenQuad(); RenderScreenQuad();
} }
mBlurShader->BlurHorizontal(mVBO, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height);
mBlurShader->BlurVertical(mVBO, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); mBlurShader->BlurVertical(this, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height);
// Add bloom back to scene texture: // Add bloom back to scene texture:
mBuffers->BindCurrentFB(); mBuffers->BindCurrentFB();

View file

@ -49,6 +49,7 @@
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/shaders/gl_blurshader.h" #include "gl/shaders/gl_blurshader.h"
#include "gl/data/gl_vertexbuffer.h" #include "gl/data/gl_vertexbuffer.h"
#include "gl/renderer/gl_renderer.h"
//========================================================================== //==========================================================================
// //
@ -56,9 +57,9 @@
// //
//========================================================================== //==========================================================================
void FBlurShader::BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) void FBlurShader::BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height)
{ {
Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true); Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true);
} }
//========================================================================== //==========================================================================
@ -67,9 +68,9 @@ void FBlurShader::BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sam
// //
//========================================================================== //==========================================================================
void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) void FBlurShader::BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height)
{ {
Blur(vbo, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false);
} }
//========================================================================== //==========================================================================
@ -78,7 +79,7 @@ void FBlurShader::BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int s
// //
//========================================================================== //==========================================================================
void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) void FBlurShader::Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical)
{ {
BlurSetup *setup = GetSetup(blurAmount, sampleCount); BlurSetup *setup = GetSetup(blurAmount, sampleCount);
if (vertical) if (vertical)
@ -111,12 +112,7 @@ void FBlurShader::Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glDisable(GL_BLEND); glDisable(GL_BLEND);
FFlatVertex *ptr = vbo->GetBuffer(); renderer->RenderScreenQuad();
ptr->Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); ptr++;
ptr->Set(-1.0f, 1.0f, 0, 0.0f, 1.0f); ptr++;
ptr->Set(1.0f, -1.0f, 0, 1.0f, 0.0f); ptr++;
ptr->Set(1.0f, 1.0f, 0, 1.0f, 1.0f); ptr++;
vbo->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
} }
//========================================================================== //==========================================================================

View file

@ -4,16 +4,16 @@
#include "gl_shaderprogram.h" #include "gl_shaderprogram.h"
#include <memory> #include <memory>
class FFlatVertexBuffer; class FGLRenderer;
class FBlurShader class FBlurShader
{ {
public: public:
void BlurVertical(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); void BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height);
void BlurHorizontal(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); void BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height);
private: private:
void Blur(FFlatVertexBuffer *vbo, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical); void Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical);
struct BlurSetup struct BlurSetup
{ {