Same for shadow blur pass
This commit is contained in:
parent
b24fd621a5
commit
c91c04c862
@ -1,7 +1,7 @@
|
||||
uniform sampler2D source;
|
||||
uniform layout(r32f) restrict writeonly image2D dest;
|
||||
uniform vec2 pixel;
|
||||
uniform float sigma;
|
||||
uniform float weights[7];
|
||||
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
@ -23,18 +23,10 @@ void main()
|
||||
|
||||
barrier();
|
||||
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
float sum = local_src[x + 6][y] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
float sum = local_src[x + 6][y] * weights[0];
|
||||
for (int i = 1; i < 6; i++) {
|
||||
sum += local_src[6 + x - i][y] * g0;
|
||||
sum += local_src[6 + x + i][y] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
sum += local_src[6 + x - i][y] * weights[i];
|
||||
sum += local_src[6 + x + i][y] * weights[i];
|
||||
}
|
||||
|
||||
imageStore(dest, iuv, vec4(sum));
|
||||
|
@ -1,7 +1,7 @@
|
||||
uniform sampler2D source;
|
||||
uniform layout(r32f) restrict writeonly image2D dest;
|
||||
uniform vec2 pixel;
|
||||
uniform float sigma;
|
||||
uniform float weights[7];
|
||||
|
||||
// Gaussian separated blur with radius 6.
|
||||
|
||||
@ -23,18 +23,10 @@ void main()
|
||||
|
||||
barrier();
|
||||
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
float sum = local_src[x][y + 6] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
float sum = local_src[x][y + 6] * weights[0];
|
||||
for (int i = 1; i < 6; i++) {
|
||||
sum += local_src[x][6 + y - i] * g0;
|
||||
sum += local_src[x][6 + y + i] * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
sum += local_src[x][6 + y - i] * weights[i];
|
||||
sum += local_src[x][6 + y + i] * weights[i];
|
||||
}
|
||||
|
||||
imageStore(dest, iuv, vec4(sum));
|
||||
|
@ -329,20 +329,43 @@ void PostProcessing::renderGaussian6BlurLayer(FrameBuffer &in_fbo, size_t layer,
|
||||
}
|
||||
else
|
||||
{
|
||||
float g0, g1, g2;
|
||||
|
||||
std::vector<float> weightsV;
|
||||
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaV);
|
||||
g1 = exp(-.5f / (sigmaV * sigmaV));
|
||||
g2 = g1 * g1;
|
||||
for (unsigned i = 0; i < 7; i++)
|
||||
{
|
||||
weightsV.push_back(g0);
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
|
||||
glUseProgram(FullScreenShader::ComputeShadowBlurVShader::getInstance()->Program);
|
||||
FullScreenShader::ComputeShadowBlurVShader::getInstance()->SetTextureUnits(LayerTex);
|
||||
glBindSampler(FullScreenShader::ComputeShadowBlurVShader::getInstance()->TU_dest, 0);
|
||||
glBindImageTexture(FullScreenShader::ComputeShadowBlurVShader::getInstance()->TU_dest, irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0], 0, false, 0, GL_WRITE_ONLY, GL_R32F);
|
||||
FullScreenShader::ComputeShadowBlurVShader::getInstance()->setUniforms(core::vector2df(1.f / 1024.f, 1.f / 1024.f), sigmaV);
|
||||
FullScreenShader::ComputeShadowBlurVShader::getInstance()->setUniforms(core::vector2df(1.f / 1024.f, 1.f / 1024.f), weightsV);
|
||||
glDispatchCompute((int)1024 / 8 + 1, (int)1024 / 8 + 1, 1);
|
||||
|
||||
std::vector<float> weightsH;
|
||||
g0 = 1.f / (sqrtf(2.f * 3.14f) * sigmaH);
|
||||
g1 = exp(-.5f / (sigmaH * sigmaH));
|
||||
g2 = g1 * g1;
|
||||
for (unsigned i = 0; i < 7; i++)
|
||||
{
|
||||
weightsH.push_back(g0);
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT | GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
glUseProgram(FullScreenShader::ComputeShadowBlurHShader::getInstance()->Program);
|
||||
FullScreenShader::ComputeShadowBlurHShader::getInstance()->SetTextureUnits(irr_driver->getFBO(FBO_SCALAR_1024).getRTT()[0]);
|
||||
glBindSampler(FullScreenShader::ComputeShadowBlurHShader::getInstance()->TU_dest, 0);
|
||||
glBindImageTexture(FullScreenShader::ComputeShadowBlurHShader::getInstance()->TU_dest, LayerTex, 0, false, 0, GL_WRITE_ONLY, GL_R32F);
|
||||
FullScreenShader::ComputeShadowBlurHShader::getInstance()->setUniforms(core::vector2df(1.f / 1024.f, 1.f / 1024.f), sigmaH);
|
||||
FullScreenShader::ComputeShadowBlurHShader::getInstance()->setUniforms(core::vector2df(1.f / 1024.f, 1.f / 1024.f), weightsH);
|
||||
glDispatchCompute((int)1024 / 8 + 1, (int)1024 / 8 + 1, 1);
|
||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||
}
|
||||
|
@ -1762,7 +1762,7 @@ namespace FullScreenShader
|
||||
Program = LoadProgram(OBJECT,
|
||||
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/blurshadowH.comp").c_str());
|
||||
TU_dest = 1;
|
||||
AssignUniforms("pixel", "sigma");
|
||||
AssignUniforms("pixel", "weights");
|
||||
AssignSamplerNames(Program, 0, "source");
|
||||
AssignTextureUnit(Program, TexUnit(TU_dest, "dest"));
|
||||
}
|
||||
@ -1832,7 +1832,7 @@ namespace FullScreenShader
|
||||
Program = LoadProgram(OBJECT,
|
||||
GL_COMPUTE_SHADER, file_manager->getAsset("shaders/blurshadowV.comp").c_str());
|
||||
TU_dest = 1;
|
||||
AssignUniforms("pixel", "sigma");
|
||||
AssignUniforms("pixel", "weights");
|
||||
AssignSamplerNames(Program, 0, "source");
|
||||
AssignTextureUnit(Program, TexUnit(TU_dest, "dest"));
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public:
|
||||
ComputeGaussian6HBlurShader();
|
||||
};
|
||||
|
||||
class ComputeShadowBlurHShader : public ShaderHelperSingleton<ComputeShadowBlurHShader, core::vector2df, float>, public TextureRead<Neared_Clamped_Filtered>
|
||||
class ComputeShadowBlurHShader : public ShaderHelperSingleton<ComputeShadowBlurHShader, core::vector2df, std::vector<float> >, public TextureRead<Neared_Clamped_Filtered>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
@ -524,7 +524,7 @@ public:
|
||||
ComputeGaussian6VBlurShader();
|
||||
};
|
||||
|
||||
class ComputeShadowBlurVShader : public ShaderHelperSingleton<ComputeShadowBlurVShader, core::vector2df, float>, public TextureRead<Neared_Clamped_Filtered>
|
||||
class ComputeShadowBlurVShader : public ShaderHelperSingleton<ComputeShadowBlurVShader, core::vector2df, std::vector<float> >, public TextureRead<Neared_Clamped_Filtered>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dest;
|
||||
|
Loading…
Reference in New Issue
Block a user