getVertexFormat.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. return {
  2. summary = 'Get the vertex format of the Mesh.',
  3. description = [[
  4. Returns the vertex format of the Mesh, which is a list of "attributes" that make up the data for
  5. each vertex (position, color, UV, etc.).
  6. ]],
  7. arguments = {},
  8. returns = {
  9. format = {
  10. type = 'table',
  11. description = 'The vertex format.',
  12. table = {
  13. {
  14. name = '[][1]',
  15. type = 'string',
  16. description = 'The name of the attribute.'
  17. },
  18. {
  19. name = '[][2]',
  20. type = 'DataType',
  21. description = 'The type of the attribute.'
  22. },
  23. {
  24. name = '[][3]',
  25. type = 'number',
  26. description = 'The byte offset of the attribute.'
  27. }
  28. }
  29. }
  30. },
  31. variants = {
  32. {
  33. arguments = {},
  34. returns = { 'format' }
  35. }
  36. },
  37. notes = [[
  38. If no vertex format is given when the Mesh is created, it will use a default format:
  39. {
  40. { 'VertexPosition', 'vec3', 0 },
  41. { 'VertexNormal', 'vec3', 12 },
  42. { 'VertexUV', 'vec2', 24 }
  43. }
  44. The name of the vertex attribute corresponds to an `in` input variable in a vertex shader.
  45. There are a few built-in attributes that all shaders will understand and use by default:
  46. <table>
  47. <thead>
  48. <tr>
  49. <td>Name</td>
  50. <td>Description</td>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <tr>
  55. <td><code>VertexPosition</code></td>
  56. <td>The position of the vertex.</td>
  57. </tr>
  58. <tr>
  59. <td><code>VertexNormal</code></td>
  60. <td>The normal vector of the vertex.</td>
  61. </tr>
  62. <tr>
  63. <td><code>VertexUV</code></td>
  64. <td>The texture coordinate of the vertex.</td>
  65. </tr>
  66. <tr>
  67. <td><code>VertexColor</code></td>
  68. <td>The color of the vertex (linear color space).</td>
  69. </tr>
  70. <tr>
  71. <td><code>VertexTangent</code></td>
  72. <td>The tangent vector of the vertex.</td>
  73. </tr>
  74. </tbody>
  75. </table>
  76. See the `Shaders` and `Meshes` guides for more info.
  77. ]],
  78. related = {
  79. 'Mesh:getVertexCount',
  80. 'Mesh:getVertexStride',
  81. 'lovr.graphics.newMesh'
  82. }
  83. }