Is vertices.normals face- or vertex-normals?

Hey, guys! Merry Christmas!

I’m working on a little holidays-project for a prototype of my game. And now I’m digging down into the nitty-gritty; making shaders! I’m not VERY familiar with all the components of a 3D mesh (or applying the correct math to the algorithm), so I need a little guidance.

I am making a deform vertex-shader for a sphere where i need to work with normals. Just to make sure that I’m on the right track, I’m trying to use a script to draw debug-rays from the vertices in the direction of each vertices normal.

private Mesh mesh;
public float normalLength = 1;

// Use this for initialization
void Start () {
        mesh = GetComponent<MeshFilter>().mesh;
}

// Update is called once per frame
void Update () {
        foreach (Vector3 v3 in mesh.normals)
        {
            Debug.DrawRay(transform.position + v3, v3 * normalLength, Color.red);
        }
}

However… This seems only to give me the face-normals. Am I doing something wrong in the script? What the hell is going on!!!

mesh.normals are the normals associated to the vertices: usually the shader calculates each pixel’s normal by interpolating among the normals. Flat surfaces have equal normals in their vertices (like if they were surface normals), but curved surfaces have different normals associated to each vertex.

Anyway, keep in mind that all data in a mesh is in local space, which doesn’t take the transform settings into account (rotation, scale, position). You should convert each vertex and its normal to world space in order to correctly display them:

void Update () {
    for (int i=0; i<mesh.vertices.Length; i++){
        Vector3 norm = transform.TransformDirection(mesh.normals*);*

Vector3 vert = transform.TransformPoint(mesh.vertices*);*
Debug.DrawRay(vert, norm * normalLength, Color.red);
}
}