Unity Exception: "Not allowed to recalculate normals on mesh"

Hello,

I’m having a lot of problems with a skinned mesh renderer not “picking up” the lighting in the scene correctly. Sections of the skinned mesh are completely black, when they should be recieving realtime lighting. I think it’s some type of shading issue using the skinnedMeshRenderer.

I tried to call mesh.RecalculateNormals(),

but I get the exception:

Not allowed to call RecalculateNormals() on mesh ‘_Sheet_v1_Decimated-r5 Instance’
UnityEngine.Mesh:RecalculateNormals()

Does anyone know why this error occur?

     MeshFilter mf = sheetGameObject.GetComponent<MeshFilter>();
     Mesh mesh = mf.mesh;
     mesh.RecalculateBounds(); //Exception

Are we not allowed to re-calculate normals on meshes used in skinned mesh renderers?
Thanks.

is Read/Write check off on the meshes import options?

2 Likes

That was the problem, the read/write was not checked. Thanks.
The exception no longer occurs, but unfortunately it still doesn’t solve the issue of the self-shading.
There is very aggressive self-shading going on and/or not picking up lighting.
I thought maybe re-calculating the normals would help.

2677482--189074--shadingLighting.jpg
I replaced the SkinnedMeshrenderer with the regular meshRenderer and the issue goes away.
Maybe now this thread is no longer belongs in the scripting section of the forums.
j

1 Like

i see this error , in android build
i think it is a bug
in the windows build there is no error
but in the android i think read&write option return false value but in the unity editor i checked it
the unity engine version is : 2021 3.3.f1