Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normal map is incorrectly compressed when using Basis Universal compression mode #61039

Closed
Calinou opened this issue May 14, 2022 · 2 comments · Fixed by #62718
Closed

Normal map is incorrectly compressed when using Basis Universal compression mode #61039

Calinou opened this issue May 14, 2022 · 2 comments · Fixed by #62718

Comments

@Calinou
Copy link
Member

Calinou commented May 14, 2022

Godot version

4.0.alpha (9923179)

System information

Fedora 36, GeForce GTX 1080 (NVIDIA 510.68.02)

Issue description

Normal map is incorrectly compressed when using Basis Universal compression mode:

image

This does not occur when using VRAM compression (which is S3TC on desktop platforms).

Steps to reproduce

  • Add a normal map to a material.
  • Change its compression mode to Basis Universal in the Import dock, then click Reimport.
  • Notice how the 3D rendering looks all wrong, and the normal map in the inspector preview is too green (the thumbnail may be outdated).

Minimal reproduction project

https://github.com/Calinou/godot-test-basis-universal
(.godot/ is included to avoid crashes due to Basis Universal importing)

The texture included in the MRP is https://polyhaven.com/a/mud_cracked_dry_03.

@lyuma
Copy link
Contributor

lyuma commented Feb 27, 2023

Changing this code works around the problem:
modules/basis_universal/register_types.cpp

                        case Image::USED_CHANNELS_RG: {
 #ifdef USE_RG_AS_RGBA
-                               image->convert_rg_to_ra_rgba8();
-                               decompress_format = BASIS_DECOMPRESS_RG_AS_RA;
+                               //image->convert_rg_to_ra_rgba8();
+                               //decompress_format = BASIS_DECOMPRESS_RG_AS_RA;
+                               decompress_format = BASIS_DECOMPRESS_RGB;

It's disabling a major optimization to how normal maps are compressed, so I don't think this is a good fix, but it confirms that the issue is caused by the RG_AS_RA case.

I don't know quite enough about what's going on here to suggest a good fix yet, but we could apply the above to disable the RG_AS_RA workaround for 4.1 or 4.0.x until we learn more.

@DeeJayLSP
Copy link
Contributor

DeeJayLSP commented May 4, 2023

This occurs in two situations, both when a normal map gets imported as Basis Universal:

  • Normal Map is set to Detect or Enabled;
  • Channel Pack is set to Optimized;

The workaround is to disable Normal Map check, leaving Channel Pack on sRGB Friendly.

@akien-mga akien-mga modified the milestones: 4.1, 4.2 Jun 16, 2023
@akien-mga akien-mga modified the milestones: 4.2, 4.1 Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment