SSAO: Stronger blur + tweak param
Use another algorithm to have gaussian blur that lets us customise radius more easily.
This commit is contained in:
parent
bba9e3ca2c
commit
26d48cdad0
@ -1,37 +1,30 @@
|
||||
// From http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
||||
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
uniform float sigma = 5.;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
|
||||
float offset[5] = {
|
||||
0.,
|
||||
1.41176470588235,
|
||||
3.29411764705882,
|
||||
5.17647058823529,
|
||||
7.05882352941176
|
||||
};
|
||||
float weight[5] = {
|
||||
0.196380615234375,
|
||||
0.1888427734375,
|
||||
0.03631591796875,
|
||||
0.0020751953125,
|
||||
0.000015258789062
|
||||
};
|
||||
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * weight[0];
|
||||
for (int i = 1; i < 5; i++) {
|
||||
sum += texture(tex, vec2(X - offset[i] * pixel.x, Y)) * weight[i];
|
||||
sum += texture(tex, vec2(X + offset[i] * pixel.x, Y)) * weight[i];
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 9; i++) {
|
||||
sum += texture(tex, vec2(X - i * pixel.x, Y)) * g0;
|
||||
sum += texture(tex, vec2(X + i * pixel.x, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
FragColor = sum;
|
||||
|
@ -1,38 +1,32 @@
|
||||
// From http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
||||
// From http://http.developer.nvidia.com/GPUGems3/gpugems3_ch40.html
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 pixel;
|
||||
|
||||
uniform float sigma = 5.;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
float X = uv.x;
|
||||
float Y = uv.y;
|
||||
|
||||
float offset[5] = {
|
||||
0.,
|
||||
1.41176470588235,
|
||||
3.29411764705882,
|
||||
5.17647058823529,
|
||||
7.05882352941176
|
||||
};
|
||||
float weight[5] = {
|
||||
0.196380615234375,
|
||||
0.1888427734375,
|
||||
0.03631591796875,
|
||||
0.0020751953125,
|
||||
0.000015258789062
|
||||
};
|
||||
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * weight[0];
|
||||
for (int i = 1; i < 5; i++) {
|
||||
sum += texture(tex, vec2(X, Y - offset[i] * pixel.y)) * weight[i];
|
||||
sum += texture(tex, vec2(X, Y + offset[i] * pixel.y)) * weight[i];
|
||||
float g0, g1, g2;
|
||||
g0 = 1.0 / (sqrt(2.0 * 3.14) * sigma);
|
||||
g1 = exp(-0.5 / (sigma * sigma));
|
||||
g2 = g1 * g1;
|
||||
vec4 sum = texture(tex, vec2(X, Y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
for (int i = 1; i < 9; i++) {
|
||||
sum += texture(tex, vec2(X, Y - i * pixel.y)) * g0;
|
||||
sum += texture(tex, vec2(X, Y + i * pixel.y)) * g0;
|
||||
g0 *= g1;
|
||||
g1 *= g2;
|
||||
}
|
||||
|
||||
FragColor = sum;
|
||||
}
|
||||
|
||||
|
@ -27,10 +27,10 @@ in vec2 uv;
|
||||
out float AO;
|
||||
|
||||
const float sigma = 1.;
|
||||
const float tau = 2.;
|
||||
const float tau = 7.;
|
||||
const float beta = 0.0001;
|
||||
const float epsilon = .00001;
|
||||
const float radius = 1.;
|
||||
const float radius = 1.5;
|
||||
const float k = 1.;
|
||||
|
||||
#define SAMPLES 16
|
||||
|
@ -899,7 +899,7 @@ void IrrDriver::renderSSAO()
|
||||
m_post_processing->renderSSAO();
|
||||
// Blur it to reduce noise.
|
||||
m_post_processing->renderGaussian17TapBlur(irr_driver->getFBO(FBO_SSAO), irr_driver->getRenderTargetTexture(RTT_SSAO),
|
||||
irr_driver->getFBO(FBO_TMP4), irr_driver->getRenderTargetTexture(RTT_TMP4), UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
irr_driver->getFBO(FBO_TMP4), irr_driver->getRenderTargetTexture(RTT_TMP4), UserConfigParams::m_width, UserConfigParams::m_height );
|
||||
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user