armory/Shaders/blur_adaptive_pass/blur_adaptive_pass.frag.glsl

33 lines
924 B
Plaintext
Raw Normal View History

2016-08-09 23:51:40 +02:00
// Exclusive to SSR for now
2016-06-21 13:29:27 +02:00
#version 450
#include "compiled.inc"
2017-12-13 14:21:42 +01:00
#include "std/gbuffer.glsl"
2016-08-09 23:51:40 +02:00
2016-06-21 13:29:27 +02:00
uniform sampler2D tex;
2016-08-07 01:43:21 +02:00
uniform sampler2D gbuffer0; // Roughness
2016-06-21 13:29:27 +02:00
2017-03-11 01:50:47 +01:00
uniform vec2 dirInv;
2016-06-21 13:29:27 +02:00
in vec2 texCoord;
2016-10-12 17:52:27 +02:00
out vec4 fragColor;
2016-06-21 13:29:27 +02:00
void main() {
2019-07-07 22:02:07 +02:00
float roughness = textureLod(gbuffer0, texCoord, 0.0).b;
2016-09-08 14:08:31 +02:00
// if (roughness == 0.0) { // Always blur for now, non blured output can produce noise
2018-12-06 15:23:08 +01:00
// fragColor.rgb = textureLod(tex, texCoord).rgb;
2016-09-08 14:08:31 +02:00
// return;
// }
2016-10-17 00:02:51 +02:00
if (roughness >= 0.8) { // No reflections
2018-12-06 15:23:08 +01:00
fragColor.rgb = textureLod(tex, texCoord, 0.0).rgb;
2016-10-17 00:02:51 +02:00
return;
}
2016-06-21 13:29:27 +02:00
2018-12-06 15:23:08 +01:00
fragColor.rgb = textureLod(tex, texCoord + dirInv * 2.5, 0.0).rgb;
fragColor.rgb += textureLod(tex, texCoord + dirInv * 1.5, 0.0).rgb;
fragColor.rgb += textureLod(tex, texCoord, 0.0).rgb;
fragColor.rgb += textureLod(tex, texCoord - dirInv * 1.5, 0.0).rgb;
fragColor.rgb += textureLod(tex, texCoord - dirInv * 2.5, 0.0).rgb;
2017-03-11 01:50:47 +01:00
fragColor.rgb /= vec3(5.0);
2016-06-21 13:29:27 +02:00
}