Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Not work on Android
#1
I use Obi Cloth for the physics of character clothes, in Unity (2018.4.14) everything works fine. But on Android (Asus ZenFone) there is no physics and there is an error in the logs.
Can you tell me what could be the problem, please?

I attach the error log + Obi settings.


Attached Files Thumbnail(s)
           
Reply
#2
Same on iOS, unity 2019.2.20f, ObiCloth 5
Reply
#3
Hi there,

Can't reproduce in either platform.
- What Obi version are each of you using? (4.0, 5.0 or 5.1?)
- Can you give more details about your setup? Specifically, what are the settings on your ObiSkinnedClothRenderer?
Reply
#4
Hi! Unity project: 

https://www.dropbox.com/s/huendo0smwr6mvc/ObiTest.zip

It does not work on Android.
Reply
#5
(02-03-2020, 12:57 PM)Denis Wrote: Hi! Unity project: 

https://www.dropbox.com/s/huendo0smwr6mvc/ObiTest.zip

It does not work on Android.


Hi Denis,

Thanks for the repro project. Will test it and get back to you asap.
Reply
#6
(02-03-2020, 01:11 PM)josemendez Wrote: Hi Denis,

Thanks for the repro project. Will test it and get back to you asap.

Thanks! I hope you can find the cause of the issue!
Reply
#7
Hi,

Switching the ObiSkinnedClothRenderer tangent space update to "Copy normals from simulation" circumvents the issue. Will take a look at why transforming tangents does not work in Android, but for the time being this is simple workaround. All other tangent update modes work fine too, only the "Transform normals and tangents" mode results in this issue.

"Transform normals and tangents" should not be needed unless you have hand-authored your mesh tangent space, or have specified per-face normals for hard edges.

Edit: Found the culprit.

Turns out, there's this flag in Unity that I didn't know about:

https://docs.unity3d.com/ScriptReference...1583224178

When enabled, it removes unused mesh data at build time. It's called "Optimize Mesh Data" in the player settings. Unless you're using a shader that makes use of normal maps (which require a tangent space to be defined), Unity will remove all tangent vector information from meshes in your build. Since Obi assumes the mesh will have both normal and tangent data, and Unity does not know that the tangent data is used by Obi, it tries to access a tangents array of length 0 resulting in the above issue. Unity's documentation does warn that if you enable this flag and do any kind of runtime shader/mesh processing, you can get unintended results.

This does not happen in the editor, because data is stripped only in the build.

Simply adding a check in Line 126 of ObiClothRendererBase:

Code:
if (meshVertexIndex < restTangents.Count)
{
    Vector3 tangent = space.MultiplyVector(delta * restTangents[meshVertexIndex]);
    clothTangents[meshVertexIndex] = new Vector4(tangent.x, tangent.y, tangent.z, clothTangents[meshVertexIndex].w);
}

Allows support for enabling stripUnusedMeshComponents.
Reply
#8
Got it!
Thanks for help!
Reply