Model.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2009-2020, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <shaders/glsl_cpp_common/Common.h>
  7. ANKI_BEGIN_NAMESPACE
  8. const U32 UV_CHANNEL_0 = 0;
  9. const U32 UV_CHANNEL_COUNT = 1;
  10. struct Vertex
  11. {
  12. U32 m_normal; // Packed in R10G10B10A2SNorm
  13. U32 m_tangent; // Packed in R10G10B10A2SNorm
  14. HVec2 m_uvs[UV_CHANNEL_COUNT];
  15. };
  16. const U32 SIZEOF_VERTEX = 4 * 3;
  17. struct Mesh
  18. {
  19. U64 m_indexBufferPtr; // Points to a buffer of U16
  20. U64 m_positionBufferPtr; // Points to a buffer of Vec3
  21. U64 m_vertexBufferPtr; // Points to a buffer of Vertex
  22. U32 m_indexCount;
  23. U32 m_vertexCount;
  24. };
  25. const U32 TEXTURE_CHANNEL_DIFFUSE = 0;
  26. const U32 TEXTURE_CHANNEL_NORMAL = 1;
  27. const U32 TEXTURE_CHANNEL_ROUGHNESS_METALNESS = 2;
  28. const U32 TEXTURE_CHANNEL_EMISSION = 3;
  29. const U32 TEXTURE_CHANNEL_HEIGHT = 4;
  30. const U32 TEXTURE_CHANNEL_AUX_0 = 5;
  31. const U32 TEXTURE_CHANNEL_AUX_1 = 6;
  32. const U32 TEXTURE_CHANNEL_AUX_2 = 7;
  33. const U32 TEXTURE_CHANNEL_COUNT = 8;
  34. struct Material
  35. {
  36. U16 m_textureIds[TEXTURE_CHANNEL_COUNT];
  37. Vec3 m_diffuseColor;
  38. Vec3 m_specularColor;
  39. Vec3 m_emissiveColor;
  40. F16 m_roughness;
  41. F16 m_metalness;
  42. };
  43. struct ModelInstance
  44. {
  45. Mesh m_mesh;
  46. Material m_material;
  47. #if defined(__cplusplus)
  48. F32 m_worldTransform[12];
  49. #else
  50. Mat3x4 m_worldTransform;
  51. #endif
  52. Mat3 m_worldRotation;
  53. };
  54. ANKI_END_NAMESPACE