Material on Instanced Static Mesh Component turns black when mesh is scaled.

I made material that subdivides texture coordinates based on object scale. When material is applied on scaled StaticMeshActor, then it works as expected without an issue.

However, when I put it on the scaled InstancedStaticMeshComponent it breaks and makes material dark and full of artifacts.

I don’t understand why is that.

Here is the material:

TileByScale function:

It gives me warnings inside instance material (image is in the comments due to number of image limitation). It might be the issue, but I don’t know how to fix it. If I change Sampler Type to Grayscale it won’t compile at all and gives me errors.

I would be very grateful for any ideas on how to fix it.
Thank you.

Material Instance warnings:

Ok, I figured the solution.
For anyone else having this problem:
In object viewer under the Build Settings check the “Use High Precision Tangent Basis”.

Deactivate TwoSided checkbox in the Material
otherwise the renderer produces black artifacts