VertexFormats.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <CryCommon/Cry_Math.h>
  10. enum EVertexFormat : uint8
  11. {
  12. eVF_Unknown,
  13. // Base stream
  14. eVF_P3F_C4B_T2F,
  15. eVF_P3S_C4B_T2S,
  16. // Additional streams
  17. eVF_W4B_I4S, // Skinned weights/indices stream.
  18. eVF_P3F, // Velocity stream.
  19. // Lens effects simulation
  20. eVF_P2F_C4B_T2F_F4B, // UI
  21. eVF_P3F_C4B,// Auxiliary geometry
  22. eVF_Max,
  23. };
  24. struct UCol
  25. {
  26. union
  27. {
  28. uint32 dcolor;
  29. uint8 bcolor[4];
  30. struct
  31. {
  32. uint8 b, g, r, a;
  33. };
  34. struct
  35. {
  36. uint8 z, y, x, w;
  37. };
  38. };
  39. // get normal vector from unsigned 8bit integers (can't point up/down and is not normal)
  40. ILINE Vec3 GetN()
  41. {
  42. return Vec3
  43. (
  44. (bcolor[0] - 128.0f) / 127.5f,
  45. (bcolor[1] - 128.0f) / 127.5f,
  46. (bcolor[2] - 128.0f) / 127.5f
  47. );
  48. }
  49. };
  50. struct Vec3f16
  51. : public CryHalf4
  52. {
  53. _inline Vec3f16()
  54. {
  55. }
  56. _inline Vec3f16(f32 _x, f32 _y, f32 _z)
  57. {
  58. x = CryConvertFloatToHalf(_x);
  59. y = CryConvertFloatToHalf(_y);
  60. z = CryConvertFloatToHalf(_z);
  61. w = CryConvertFloatToHalf(1.0f);
  62. }
  63. float operator[](int i) const
  64. {
  65. assert(i <= 3);
  66. return CryConvertHalfToFloat(((CryHalf*)this)[i]);
  67. }
  68. _inline Vec3f16& operator = (const Vec3& sl)
  69. {
  70. x = CryConvertFloatToHalf(sl.x);
  71. y = CryConvertFloatToHalf(sl.y);
  72. z = CryConvertFloatToHalf(sl.z);
  73. w = CryConvertFloatToHalf(1.0f);
  74. return *this;
  75. }
  76. _inline Vec3f16& operator = (const Vec4& sl)
  77. {
  78. x = CryConvertFloatToHalf(sl.x);
  79. y = CryConvertFloatToHalf(sl.y);
  80. z = CryConvertFloatToHalf(sl.z);
  81. w = CryConvertFloatToHalf(sl.w);
  82. return *this;
  83. }
  84. _inline Vec3 ToVec3() const
  85. {
  86. Vec3 v;
  87. v.x = CryConvertHalfToFloat(x);
  88. v.y = CryConvertHalfToFloat(y);
  89. v.z = CryConvertHalfToFloat(z);
  90. return v;
  91. }
  92. };
  93. struct SVF_P3F_C4B
  94. {
  95. Vec3 xyz;
  96. UCol color;
  97. };
  98. struct SVF_P3F_C4B_T2F
  99. {
  100. Vec3 xyz;
  101. UCol color;
  102. Vec2 st;
  103. };
  104. struct SVF_P2F_C4B_T2F_F4B
  105. {
  106. Vec2 xy;
  107. UCol color;
  108. Vec2 st;
  109. uint8 texIndex;
  110. uint8 texHasColorChannel;
  111. uint8 texIndex2;
  112. uint8 pad;
  113. };
  114. struct SVF_P3F
  115. {
  116. Vec3 xyz;
  117. };