Question about Vertex Function return value

Doctor Caroline:

     I have a question to ask:  whether I must need to return vertex in vertex function when I use translation matrix to translate in vertex function? 
   
     if the vertex function without translation matrix to use, I can only return position that is struct vertex's member.
  
   Would u please tell me whether I can think it so?

When you create your vertex function, you specify the return value.

In Chapter 3, your vertex header is:

vertex float4 vertex_main(const VertexIn vertexIn [[stage_in]])

That means that you have to return a float4 from the vertex function. It doesn’t matter what you do inside the vertex function - you can do all sorts of wonders with matrices - or nothing at all. The only requirement is that you return a float4 from the function at the end of it.

Later on in the book, you create a VertexOut struct and return that from the vertex function.

The header for that would be:

vertex VertexOut vertex_main(const VertexIn vertexIn [[stage_in]])

That tells the vertex function that you are returning a VertexOut.

Okay I got it. I thought whether there are some hidden rule. Thanks for your help