I use v.noraml to moving the vertex position,but when negative scale ,the moving is wrong,how to fixed this?
it seems make the v.normal normalized when scale.x=-1,why?
Show us the code.
Generally you can’t use model matrix to transform direction vectors when scale is nonuniform (as in your case, x = -1, y = z = 1), only position ones.
For completely generic matrix you should use inverse transpose matrix (see Unity - Scripting API: Matrix4x4.transpose and Unity - Scripting API: Matrix4x4.inverse methods) to get corresponding transformation matrix for direction vectors.
In your case I think there should be more simpler solution, but I am too lazy now to get the paper and calculate it.
Transforming Normals [RMS] - explanation of why you can’t transform normals with non-uniform scale matrix
Thanks your reply !my code is very simple.give difference vector for vetex normal .like this:mesh.normal=dirs;then in shader:float3 pos =v.vertex;pos=pos+time.y*v.normal;I don’t use the matrix to scale,it is unity do it.
Help
i want to use unity_scale for control nonuniform scale and v.normal by this:
v.normal=v.normal*unity_scale.w;it dosen’t work…
c#
Start():
Matrix4x4 invertTraM=new Matrix4x4();
invertTraM.SetTRS(Vector3.zero, Quaternion.identity, gameObject.transform.lossyScale);
invertTraM=invertTraM.transpose;
invertTraM=invertTraM.inverse;
renderer.material.SetMatrix("_inverTraM",invertTraM);
shader:
half3 vNormal=mul((float3x3)_inverTraM,v.normal);
hi mholub,I try use the matrix to fixed that,but my code not work,need your help,thanks advance!
and i found this very very old thread about same problem…NO WAY to fixed this??..
maybe this work?But new mesh in runtime how to enable this?
Any help?
so after all any idea ?
Hey @dreamerflyer did you find any solution ??
please reply

