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!!!