MOS
material.hpp
1 #pragma once
2 #include <glm/glm.hpp>
3 #include <memory>
4 #include <mos/gfx/texture_2d.hpp>
5 #include <string>
6 
7 namespace mos::gfx {
8 
9 class Assets;
10 
12 class Material final {
13 public:
14  template <class T> struct Slot {
15  Slot(const T &value) : value(value) {}
16  Slot(const Shared_texture_2D &texture) : texture(texture) {}
17  Slot(const T &value, const Shared_texture_2D &texture)
18  : value(value), texture(texture) {}
19  T value = T();
20  Shared_texture_2D texture = Shared_texture_2D();
21  };
22 
23  struct Normal {
24  Shared_texture_2D texture;
25  };
26 
27  static auto load(Assets &assets, const std::string &path) -> Material;
28 
29  using Albedo = Slot<glm::vec3>;
30  using Roughness = Slot<float>;
31  using Metallic = Slot<float>;
32  using Emission = Slot<glm::vec3>;
34 
35  Albedo albedo{glm::vec3(0.0f)};
36  Metallic metallic{0.0f};
37  Roughness roughness{1.0f};
38  Emission emission{glm::vec3(0.0f)};
39  Ambient_occlusion ambient_occlusion{1.0f};
40  Normal normal{};
41 
42  float alpha{1.0f};
43  float index_of_refraction{1.5f};
44  float transmission{0.0f};
45 };
46 } // namespace mos::gfx
Physically based material.
Definition: material.hpp:12
Cache for faster loading of textures and meshes.
Definition: assets.hpp:20
Definition: material.hpp:14
Definition: assets.hpp:17
Definition: material.hpp:23