PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Graphics/VertexElementType.cs

#
C# | 117 lines | 18 code | 11 blank | 88 comment | 0 complexity | e8b2a561923a70fcb7abedc31fac1fd2 MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.Utilities.Graphics
  2. {
  3. /// <summary>
  4. /// Vertex element. Currently used to dynamically create vertex data,
  5. /// flags are combined to create a specific format. Data is always aligned
  6. /// in the same order as specified here. Usage for channels (e.g. texture
  7. /// channel 0, 1, etc.) is defined by number of UVs used (TexturedUV is
  8. /// usually in channel 0, then whatever UV comes next is channel 1, etc.).
  9. /// Note: All the byte sizes should be kept in sync with the VertexFormat
  10. /// GetVertexDataLength helper method!
  11. /// </summary>
  12. public enum VertexElementType
  13. {
  14. /// <summary>
  15. /// 2D position data (Point, 2 floats = 8 bytes).
  16. /// If compressed form (2 shorts = 4 bytes, ranging from
  17. /// 0 to 16k instead of 0.0-1.0, this way we have enough values to go from
  18. /// -2.0 to +2.0, which is good enough for 2D UI).
  19. /// Note: The ScreenSpace.ViewProjection2DViaShorts must be scaled correctly to
  20. /// account for this scaling (1.0f/16384.0f) before rendering.
  21. /// </summary>
  22. Position2D,
  23. /// <summary>
  24. /// 3D position data (Vector, 3 floats = 12 bytes). Note: Often used in
  25. /// combination with the other compressed data types because it is just
  26. /// easier to use and does not require handling in the vertex shader
  27. /// If compressed form (3 shorts = 6 bytes). Each short
  28. /// is ranging from -32k to +32k and needs to be scaled with the world
  29. /// matrix of the model to account for the scaling factor needed. This
  30. /// scaling is based on VertexData.Position3DCompressedMultiplier, which
  31. /// is 1/256.0f, which allows 3D positions from -128.0f to +128.0f.
  32. /// Note: After Position3DCompressed the offset is 6 bytes, which is NOT
  33. /// 4 byte aligned, thus the next data type should be short, not float,
  34. /// else our performance will be killed (just use only Compressed).
  35. /// </summary>
  36. Position3D,
  37. /// <summary>
  38. /// Normal vector data for light calculation and normal mapping (Vector,
  39. /// 3 floats = 12 bytes). If compressed, then just 3 normalized bytes are
  40. /// used +1 byte padding (because it all has to be 4 byte aligned).
  41. /// </summary>
  42. Normal,
  43. /// <summary>
  44. /// Tangent vector for normal mapping (Vector, 3 floats = 12 bytes).
  45. /// If compressed, then just 3 normalized bytes are used +1 byte padding
  46. /// (because it all has to be 4 byte aligned).
  47. /// </summary>
  48. Tangent,
  49. /// <summary>
  50. /// Binormal vector for normal mapping (Vector, 3 floats = 12 bytes).
  51. /// If compressed, then just 3 normalized bytes are used +1 byte padding
  52. /// (because it all has to be 4 byte aligned).
  53. /// </summary>
  54. Binormal,
  55. /// <summary>
  56. /// Color for this vertex (Color, 4 bytes).
  57. /// </summary>
  58. Color,
  59. /// <summary>
  60. /// UV data (Point, 2 floats = 8 bytes)
  61. /// Compressed UV data as shorts (2 shorts = 4 bytes), while the data is
  62. /// very small, it needs to be converted from shorts to real UVs for use
  63. /// in the vertex shader (done automatically in OpenGL ES via normalize,
  64. /// 1/32k is the scaling, see VertexData.TextureUVCompressedMultiplier).
  65. /// </summary>
  66. TextureUV,
  67. /// <summary>
  68. /// UVW 3D texture data for cube mapping or reflection cube maps
  69. /// (Vector, 3 floats = 12 bytes).
  70. /// UVW 3D texture data in compressed form for cube mapping or reflection
  71. /// cube maps (3 shorts = 6 bytes), same rules as for TextureUVCompressed
  72. /// apply here too (1/32k automatically performed in OpenGL ES).
  73. /// </summary>
  74. TextureUVW,
  75. /// <summary>
  76. /// Optional light map UV channel (secondary texture channel). Please note
  77. /// that most texture channels all use the same TextureUV data (e.g.
  78. /// DiffuseMap, NormalMap and SpecularMap), but LightMap has extra UVs.
  79. /// Uses Point, 2 floats = 8 bytes.
  80. /// Optional light map UV channel in compressed form, same rules as for
  81. /// TextureUVCompressed apply here (2 shorts = 4 bytes, 1/32k scaling).
  82. /// </summary>
  83. LightMapUV,
  84. /// <summary>
  85. /// Extra UV channel for crazy purposes :D (Point, 2 floats = 8 bytes).
  86. /// Compressed form, same rules as for
  87. /// TextureUVCompressed apply here (2 shorts = 4 bytes, 1/32k scaling).
  88. /// </summary>
  89. ExtraUV,
  90. /// <summary>
  91. /// Skin indices as compressed data for the skin weights, just 2 shorts,
  92. /// should be used together with SkinWeight for 4 byte alignment. This
  93. /// could also be optimized to 2 bytes, but then our vertex data is not
  94. /// longer 4 byte aligned (which is not allowed in DirectX/XNA and can
  95. /// sometimes be bad for performance in OpenGL, but usually supported).
  96. /// Note: Unlike most other vertex element flags this one has no
  97. /// compressed counterpart and is not normalized, the format is fine.
  98. /// </summary>
  99. SkinIndices,
  100. /// <summary>
  101. /// Skin weight data for skinning (just 2 normalized shorts = 4 bytes).
  102. /// Will be automatically normalized when passed to the vertex shader.
  103. /// </summary>
  104. SkinWeights,
  105. }
  106. }