gzdoom-gles/src/gl/shaders/gl_blurshader.h

41 lines
1.3 KiB
C
Raw Normal View History

2016-07-27 19:50:30 +00:00
#ifndef __GL_BLURSHADER_H
#define __GL_BLURSHADER_H
#include "gl_shaderprogram.h"
#include <memory>
class FGLRenderer;
2016-07-27 19:50:30 +00:00
class FBlurShader
{
public:
void BlurVertical(FGLRenderer *renderer, 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);
2016-07-27 19:50:30 +00:00
private:
void Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical);
2016-07-27 19:50:30 +00:00
struct BlurSetup
{
BlurSetup(float blurAmount, int sampleCount) : blurAmount(blurAmount), sampleCount(sampleCount) { }
float blurAmount;
int sampleCount;
std::shared_ptr<FShaderProgram> VerticalShader;
std::shared_ptr<FShaderProgram> HorizontalShader;
2016-07-31 01:54:16 +00:00
FBufferedUniform1f VerticalScaleX, VerticalScaleY;
FBufferedUniform1f HorizontalScaleX, HorizontalScaleY;
2016-07-27 19:50:30 +00:00
};
BlurSetup *GetSetup(float blurAmount, int sampleCount);
FString VertexShaderCode();
FString FragmentShaderCode(float blurAmount, int sampleCount, bool vertical);
float ComputeGaussian(float n, float theta);
void ComputeBlurSamples(int sampleCount, float blurAmount, TArray<float> &sample_weights, TArray<int> &sample_offsets);
TArray<BlurSetup> mBlurSetups;
};
#endif