Merge pull request #44293 from lawnjelly/normal_compression

Fix bug in normal map decompression
This commit is contained in:
Rémi Verschelde 2020-12-11 13:38:00 +01:00 committed by GitHub
commit 00d9ffe012
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -455,7 +455,7 @@ void main() {
if (use_default_normal) { if (use_default_normal) {
normal.xy = texture2D(normal_texture, uv).xy * 2.0 - 1.0; normal.xy = texture2D(normal_texture, uv).xy * 2.0 - 1.0;
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); normal.z = sqrt(max(0.0, 1.0 - dot(normal.xy, normal.xy)));
normal_used = true; normal_used = true;
} else { } else {
normal = vec3(0.0, 0.0, 1.0); normal = vec3(0.0, 0.0, 1.0);

View file

@ -549,7 +549,7 @@ void main() {
if (use_default_normal) { if (use_default_normal) {
normal.xy = textureLod(normal_texture, uv, 0.0).xy * 2.0 - 1.0; normal.xy = textureLod(normal_texture, uv, 0.0).xy * 2.0 - 1.0;
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); normal.z = sqrt(max(0.0, 1.0 - dot(normal.xy, normal.xy)));
normal_used = true; normal_used = true;
} else { } else {
normal = vec3(0.0, 0.0, 1.0); normal = vec3(0.0, 0.0, 1.0);