atteneder / glTFast

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

glTFast render shadow received by 3D model falsely when unity normal map encoding is DXT5nm on Android #694

Open uncle-jerry opened 1 month ago

uncle-jerry commented 1 month ago

Describe the bug glTFast render shadow received by 3D model falsely when unity normal map encoding is DXT5nm on Android.

To Reproduce Steps to reproduce the behavior:

  1. Set normal map encoding method to DXT5nm-style in Android Player Settings (which is default for Unity). image

Android (please complete the following information):

HunterProduction commented 2 weeks ago

I can confirm the problem. Switching back to XYZ encoding solves the issue.

atteneder commented 2 weeks ago

Thanks for reporting.

TIL: there's an alternative normal map encoding in Unity :)

Unfortunately glTF has XYZ normals on board (see glTF 2.0 spec). There's three solutions I can think of:

  1. Stick with XYZ. Proven to work (feel free to educate me what's the benefit of DXTnm. Appreciated)
  2. Convert XYZ normal map textures to NM textures at runtime. This would come at a certain performance cost though.
  3. Use NM normal maps in glTF, along with an extension that indicates that. I know, for example, that you can create two component normals KTX BasisLZ files (see --normal-mode parameter of the ktx CLI tool). Only a solution if you're in control of the glTFs and willing to edit them all.

In any case, a warning of some sorts would be helpful as well as a mention in the docs.