Fix bug in normal map decompression

Not clamping the range here leads to dithering artifacts.
This commit is contained in:
lawnjelly 2020-12-11 10:18:12 +00:00
parent b5e8b48bb7
commit e13040b373
2 changed files with 2 additions and 2 deletions

View file

@ -455,7 +455,7 @@ void main() {
if (use_default_normal) {
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;
} else {
normal = vec3(0.0, 0.0, 1.0);

View file

@ -549,7 +549,7 @@ void main() {
if (use_default_normal) {
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;
} else {
normal = vec3(0.0, 0.0, 1.0);