Eevee: Fix incorrect padding in octahedral mapping

This fixes T54439
This commit is contained in:
Clément Foucault 2018-07-04 15:40:56 +02:00
parent a232b4926f
commit c767523727
Notes: blender-bot 2023-02-14 06:05:22 +01:00
Referenced by issue #54439, Reflection cubemap error bettween 1024 and 2048 in eevee.
5 changed files with 5 additions and 22 deletions

View File

@ -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 */

View File

@ -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) */

View File

@ -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) */

View File

@ -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;

View File

@ -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;
}