[Bf-blender-cvs] [0ab8b93fdd5] blender2.8: Eevee: SSR: Blur Mipmaps more.

Clément Foucault noreply at git.blender.org
Thu Aug 10 15:48:08 CEST 2017


Commit: 0ab8b93fdd548174cc8c5b05e239cfec7179ab61
Author: Clément Foucault
Date:   Wed Aug 9 15:31:57 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB0ab8b93fdd548174cc8c5b05e239cfec7179ab61

Eevee: SSR: Blur Mipmaps more.

Cost is negligeable (Only 0.02 ms more) and it improve stability.

===================================================================

M	source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
M	source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl

===================================================================

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 1e57aec5ea2..fc29079cf19 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl
@@ -8,8 +8,20 @@ out vec4 FragColor;
 
 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, uvs, 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, 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;
+#endif
 }
\ No newline at end of file
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..44e0c176010 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
@@ -12,20 +12,20 @@ out vec4 FragColor;
 
 void main()
 {
-	/* 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;
-
-	FragColor /= 4.0;
+#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;
 #endif
-
-	FragColor = texture(source, vec3(uvs, layer));
 }
\ No newline at end of file




More information about the Bf-blender-cvs mailing list