I discovered a bug on Unreal Engine 4.22, when I scale a static mesh along X only or Y only or Z only with scale 0.01 then the object doesn’t become a plane because the normal is not transformed.

Let me share with you my code that I wrote by myself, I share it to help you how to fix the bug.

```
matrix **Scale(float3 v)** {
return matrix(v.x, 0, 0, 0,
0, v.y, 0, 0,
0, 0, v.z, 0,
0, 0, 0, 1
);
}
void Obj::CalculateTransformMatrices() {
if (m_isTransformCalculated == false) {
m_isTransformCalculated = true;
// R = RotateX * RotateY * RotateZ
matrix R = IdentityMatrix();
R = mul(R, Rotate(float3(1, 0, 0), m_rotation.x));
R = mul(R, Rotate(float3(0, 1, 0), m_rotation.y));
R = mul(R, Rotate(float3(0, 0, 1), m_rotation.z));
// M = Scale * R * Translate
matrix M = IdentityMatrix();
M = mul(M, Scale(m_scale));
M = mul(M, R);
M = mul(M, Translate(m_location));
m_transform = M;
// M^-1
m_invertTransform = M.Invert();
// Transform for normals: Scale^-1 * R
float3x3 S_1 = (float3x3)**Scale(float3(
1.0f / m_scale.x,
1.0f / m_scale.y,
1.0f / m_scale.z
)**);
m**_transformForNormals** = mul(S_1, (float3x3)R);
} }
```

And here is the Vertex Shader (HLSL):

```
void main(ShaderVertex input, out PS_Input output)
{
output.position = mul(float4(input.position, 1), g_worldViewProjectionMatrix);
output.normal = mul(input.normal, (float3x3)**g_transformForNormals**);
output.texCoord = input.texCoord;
}
```

Edit:

The code I shared above is too complicate because I use a matrix, so here is the very easy method: