diff options
author | YimingWu <xp8110@outlook.com> | 2021-03-10 02:59:23 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2021-03-10 02:59:23 +0300 |
commit | 9166075cbeb4163566bf943f7844759702147a8a (patch) | |
tree | 1109502274df385ceabfbb3707a56e164c121edc /source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl | |
parent | 10c097eff0416368bf769c3349e9c81c12f19d5f (diff) | |
parent | 53b82efed66baddff3b7ef6c93a919ef10f4ef42 (diff) |
Merge remote-tracking branch 'origin/master' into lanpr-under-gp
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl index a4637b9df91..5bf850fe229 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl @@ -1,5 +1,9 @@ + +#pragma BLENDER_REQUIRE(common_math_lib.glsl) + /** - * Simple down-sample shader. Takes the average of the 4 texels of lower mip. + * Simple down-sample shader. + * Do a gaussian filter using 4 bilinear texture samples. */ uniform sampler2D source; @@ -14,24 +18,25 @@ float brightness(vec3 c) void main() { -#if 0 - /* Reconstructing Target uvs like this avoid missing pixels if NPO2 */ - vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0)); + vec2 texel_size = 1.0 / vec2(textureSize(source, 0)); + vec2 uvs = gl_FragCoord.xy * texel_size; +#ifdef COPY_SRC FragColor = textureLod(source, uvs, 0.0); + FragColor = safe_color(FragColor); + + /* Clamped brightness. */ + float luma = max(1e-8, brightness(FragColor.rgb)); + FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma; + #else - vec2 texel_size = 1.0 / vec2(textureSize(source, 0)); - vec2 uvs = gl_FragCoord.xy * 2.0 * texel_size; vec4 ofs = texel_size.xyxy * vec4(0.75, 0.75, -0.75, -0.75); + uvs *= 2.0; FragColor = textureLod(source, uvs + ofs.xy, 0.0); FragColor += textureLod(source, uvs + ofs.xw, 0.0); FragColor += textureLod(source, uvs + ofs.zy, 0.0); FragColor += textureLod(source, uvs + ofs.zw, 0.0); FragColor *= 0.25; - - /* Clamped brightness. */ - float luma = max(1e-8, brightness(FragColor.rgb)); - FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma; #endif } |