The elements of vertex data are called vertex attributes.
Every vertex can have the following attributes:
Internally, all vertex data is stored in separate arrays of the same size. If your meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary contains an array with 10 vertex positions, it also has arrays with 10 elements for each other vertex attribute that it uses.
In C#, Unity describes the available vertex attributes with the VertexAttribute enum. You can check whether an instance of the Mesh
class has a given vertex attribute with the Mesh.HasVertexAttribute function.
The vertex position represents the position of the vertex in object space.
Unity uses this value to determine the surface of the mesh.
This vertex attribute is required for all meshes.
In the Mesh
class, the simplest way to access this data is with Mesh.GetVertices and Mesh.SetVertices. Unity also stores this data in Mesh.vertices, but this older property is less efficient and user-friendly.
The vertex normal represents the direction that points directly “out” from the surface at the position of the vertex.
Unity uses this value to calculate the way that light reflects off the surface of a mesh.
This vertex attribute is optional.
In the Mesh
class, the simplest way to access this data is with Mesh.GetNormals and Mesh.SetNormals. Unity also stores this data in Mesh.normals, but this older property is less efficient and user-friendly.
The vertex tangent represents the direction that points along the “u” (horizontal texture) axis of the surface at the position of the vertex.
Unity stores the vertex tangent with an additional piece of data, in a four-component vector. The x,y,z components of the vector describe the tangent, and the w component of the vector describes its orientation. Unity uses the w value to compute the binormal, which is the cross product of the tangent and normal.
Unity uses the tangent and binormal values in normal mapping.
This vertex attribute is optional.
In the Mesh
class, the simplest way to access this data is with Mesh.GetTangents and Mesh.SetTangents. Unity also stores this data in Mesh.tangents, but this older property is less efficient and user-friendly.
A mesh can contain up to eight sets of texture coordinates. Texture coordinates are commonly called UVs, and the sets are called channels.
Unity uses texture coordinates when it “wraps” a texture around the mesh. The UVs indicate which part of the texture aligns with the mesh surface at the vertex position.
UV channels are commonly called “UV0” for the first channel, “UV1” for the second channel, and so on up to “UV7”. The channels respectively map to the shaderA program that runs on the GPU. More info
See in Glossary semantics TEXCOORD0
, TEXCOORD1
, and so on up to TEXCOORD7
.
By default, Unity uses the first channel (UV0) to store UVs for regular textures such as diffuse maps and specular maps. Unity can use the second channel (UV1) to store baked lightmapA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary UVs, and the third channel (UV2) to store input data for real-time lightmap UVs. For more information on lightmap UVs and how Unity uses these channels, see Lightmap UVs.
All eight texture coordinate attributes are optional.
In the Mesh
class, the simplest way to access this data is with Mesh.GetUVs and Mesh.SetUVs. Unity also stores this data in the following properties: Mesh.uv, Mesh.uv2, Mesh.uv3 and so on, up to Mesh.uv8. Note that these older properties are less efficient and user-friendly.
The vertex color represents the base color of a vertex, if any.
This color exists independently of any textures that the mesh may use.
This vertex attribute is optional.
In the Mesh
class, the simplest way to access this data is with Mesh.GetColors and Mesh.SetColors. Unity also stores this data in Mesh.colors, but this older property is less efficient and user-friendly.
In a skinned mesh, blend indices indicate which bones affects a vertex, and bone weights describe how much influence those bones have on the vertex.
In Unity, these vertex attributes are stored together.
Unity uses blend indices and bone weights to deform a skinned mesh based on the movement of its skeleton. For more information, see Skinned Mesh Renderer.
These vertex attributes are required for skinned meshes.
In the past, Unity only allowed up to 4 bones to influence a vertex. It stored this data in a BoneWeight struct, in the Mesh.boneWeights array. Now, Unity allows up to 256 bones to influence a vertex. It stores this data in a BoneWeight1 struct, and you can access it with Mesh.GetAllBoneWeights and Mesh.SetBoneWeights. For more information, read the linked API documentation.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.