diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2017-08-19 14:02:03 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2017-08-19 14:02:03 +0300 |
commit | 45f0f3dc0457a53a25103784f0e0d100c7a17cbe (patch) | |
tree | 94767d8e4fa6ea23f2bbd2274f239ecbbdc5931a /source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl | |
parent | 0d67f8d5c46fcc97cbb0544ef7d8c3c0056025c4 (diff) | |
parent | 9a262ed47ecb1c9f43053b0653364c59d9595fdf (diff) |
Merge branch 'blender2.8' into strand_editmode
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl index c2ef085ca01..3b3abdef00c 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl @@ -3,29 +3,38 @@ **/ uniform sampler2DArray source; -uniform vec2 texelSize; +uniform float fireflyFactor; in vec2 uvs; flat in float layer; out vec4 FragColor; -void main() +float brightness(vec3 c) { - /* Reconstructing Target uvs like this avoid missing pixels */ - vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0).xy); - -#if 0 /* Slower and does not match the main framebuffer downsampling. */ - /* Downsample with a 4x4 box filter */ - vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1); - - FragColor = texture(source, vec3(uvs + d.xy, layer)).rgba; - FragColor += texture(source, vec3(uvs + d.zy, layer)).rgba; - FragColor += texture(source, vec3(uvs + d.xw, layer)).rgba; - FragColor += texture(source, vec3(uvs + d.zw, layer)).rgba; + return max(max(c.r, c.g), c.b); +} - FragColor /= 4.0; +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)); + + FragColor = textureLod(source, vec3(uvs, layer), 0.0); +#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); + + FragColor = textureLod(source, vec3(uvs + ofs.xy, layer), 0.0); + FragColor += textureLod(source, vec3(uvs + ofs.xw, layer), 0.0); + FragColor += textureLod(source, vec3(uvs + ofs.zy, layer), 0.0); + FragColor += textureLod(source, vec3(uvs + ofs.zw, layer), 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 - - FragColor = texture(source, vec3(uvs, layer)); }
\ No newline at end of file |