[Bf-blender-cvs] [c7675237278] blender2.8: Eevee: Fix incorrect padding in octahedral mapping

Clément Foucault noreply at git.blender.org
Wed Jul 4 15:58:29 CEST 2018


Commit: c76752372784ce44d1647df77109b2813bdd67eb
Author: Clément Foucault
Date:   Wed Jul 4 15:40:56 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc76752372784ce44d1647df77109b2813bdd67eb

Eevee: Fix incorrect padding in octahedral mapping

This fixes T54439

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

M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
M	source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
M	source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
M	source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl

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

diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 346938b19f8..0b97496700a 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -1091,20 +1091,7 @@ static void glossy_filter_probe(
 		float bias = (i == 0) ? -1.0f : 1.0f;
 		pinfo->texel_size = 1.0f / mipsize;
 		pinfo->padding_size = powf(2.0f, (float)(maxlevel - min_lod_level - 1 - i));
-		/* XXX : WHY THE HECK DO WE NEED THIS ??? */
-		/* padding is incorrect without this! float precision issue? */
-		if (pinfo->padding_size > 32) {
-			pinfo->padding_size += 5;
-		}
-		if (pinfo->padding_size > 16) {
-			pinfo->padding_size += 4;
-		}
-		else if (pinfo->padding_size > 8) {
-			pinfo->padding_size += 2;
-		}
-		else if (pinfo->padding_size > 4) {
-			pinfo->padding_size += 1;
-		}
+		pinfo->padding_size *= pinfo->texel_size;
 		pinfo->layer = probe_idx;
 		pinfo->roughness = (float)i / ((float)maxlevel - 4.0f);
 		pinfo->roughness *= pinfo->roughness; /* Disney Roughness */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
index 14fd6d3dff5..7cf4259a938 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_diffuse_frag.glsl
@@ -131,8 +131,7 @@ void main()
 
 	/* Add a N pixel border to ensure filtering is correct
 	 * for N mipmap levels. */
-	uvs += uvs * texelSize * paddingSize * 2.0;
-	uvs -= texelSize * paddingSize;
+	uvs = (uvs - texelSize * paddingSize) / (1.0 - 2.0 * texelSize * paddingSize);
 
 	/* edge mirroring : only mirror if directly adjacent
 	 * (not diagonally adjacent) */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
index e4199e6a5ed..bb23051b7e5 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_glossy_frag.glsl
@@ -30,8 +30,7 @@ void main() {
 
 	/* Add a N pixel border to ensure filtering is correct
 	 * for N mipmap levels. */
-	uvs += uvs * texelSize * paddingSize * 2.0;
-	uvs -= texelSize * paddingSize;
+	uvs = (uvs - paddingSize) / (1.0 - 2.0 * paddingSize);
 
 	/* edge mirroring : only mirror if directly adjacent
 	 * (not diagonally adjacent) */
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
index 211fa8f0ce8..083d2313337 100644
--- a/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lightprobe_filter_visibility_frag.glsl
@@ -49,8 +49,7 @@ void main()
 	cos.xy = (vec2(texel) + 0.5) * storedTexelSize;
 
 	/* add a 2 pixel border to ensure filtering is correct */
-	cos.xy *= 1.0 + storedTexelSize * 2.0;
-	cos.xy -= storedTexelSize;
+	cos.xy = (cos.xy - storedTexelSize) / (1.0 - 2.0 * storedTexelSize);
 
 	float pattern = 1.0;
 
diff --git a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
index 631b325ae37..ec13c885bbb 100644
--- a/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/octahedron_lib.glsl
@@ -13,8 +13,7 @@ vec2 mapping_octahedron(vec3 cubevec, vec2 texel_size)
 	vec2 uvs = cubevec.xy * (0.5) + 0.5;
 
 	/* edge filtering fix */
-	uvs *= 1.0 - 2.0 * texel_size;
-	uvs += texel_size;
+	uvs = (1.0 - 2.0 * texel_size) * uvs + texel_size;
 
 	return uvs;
 }



More information about the Bf-blender-cvs mailing list