atteneder / glTFast

Efficient glTF 3D import / export package for Unity
Other
1.25k stars 251 forks source link

Unity 2022.2 - Normal maps are not interpreted correctly on Android when player settings use the default DXT5nm encoding #553

Open benpurdy opened 1 year ago

benpurdy commented 1 year ago

When the platform is set to Android, normal maps are not interpreted correctly when "Normal map encoding" value is set to DXT5nm in the player settings. This seems to be an issue in newer versions of Unity as I see this happen with 2022.2.1f1 but it does not occur in Unity 2021.3.7f1.

I have attached two screenshots illustrating the difference when changing the "Normal map encoding" value from "DXT5nm-style" to "XYZ". The "XYZ" encoding looks correct, the "DXT5nm-style" encoding looks incorrect.

Steps to reproduce the behavior:

  1. Create a project in Unity 2022.2.1f1 and import the GLTFast library.
  2. In the Build Settings window, change the platform to "Android"
  3. Add a GLTF asset to the project which includes normal maps.
  4. Add the GLTF asset to the scene.
  5. Observe the GLTF model, the reflected skybox will look strange and sort of "inside-out"
  6. Open Project Settings -> Player -> Android Settings -> Other Settings
  7. Change the "Normal Map Encoding" option to "XYZ"
  8. Observe the GLTF model, the reflected skybox will look correct.

Expected behavior

The GLTFast import/loading logic should respect the current normal map encoding settings when loading normal maps.

Screenshots

Here is the bug, when "normal map encoding" is set to DXT5nm-style

Incorrect - normal map encoding set to dxt5nm

Here is the same asset with "normal map encoding" set to XYZ

Correct - normal map encoding set to XYZ

Desktop

benpurdy commented 1 year ago

It occurs to me that this issue could related to #552