Unravel Engine C++ Reference
Loading...
Searching...
No Matches
standard_material.cpp
Go to the documentation of this file.
2#include "material.hpp"
3
6
9
11
12namespace unravel
13{
14
16{
17 entt::meta_factory<pbr_material>{}
18 .type("pbr_material"_hs)
20 entt::attribute{"name", "pbr_material"},
21 entt::attribute{"pretty_name", "PBR Material"},
22 })
23 .base<material>()
24 .func<&pbr_material::get_meta_type>("get_meta_type"_hs)
25 .func<&pbr_material::get_static_meta_type>("get_static_meta_type"_hs)
26 .func<&pbr_material::as_derived>("as_derived"_hs)
27 .data<&pbr_material::set_base_color, &pbr_material::get_base_color>("base_color"_hs)
29 entt::attribute{"name", "base_color"},
30 entt::attribute{"pretty_name", "Base Color"}
31 })
32 .data<&pbr_material::set_subsurface_color, &pbr_material::get_subsurface_color>("subsurface_color"_hs)
34 entt::attribute{"name", "subsurface_color"},
35 entt::attribute{"pretty_name", "Subsurface Color"}
36 })
37 .data<&pbr_material::set_emissive_color, &pbr_material::get_emissive_color>("emissive_color"_hs)
39 entt::attribute{"name", "emissive_color"},
40 entt::attribute{"pretty_name", "Emissive Color"}
41 })
42 .data<&pbr_material::set_roughness, &pbr_material::get_roughness>("roughness"_hs)
44 entt::attribute{"name", "roughness"},
45 entt::attribute{"pretty_name", "Roughness"},
46 entt::attribute{"min", 0.0f},
47 entt::attribute{"max", 1.0f},
48 })
49 .data<&pbr_material::set_metalness, &pbr_material::get_metalness>("metalness"_hs)
51 entt::attribute{"name", "metalness"},
52 entt::attribute{"pretty_name", "Metalness"},
53 entt::attribute{"min", 0.0f},
54 entt::attribute{"max", 1.0f},
55 })
56 .data<&pbr_material::set_bumpiness, &pbr_material::get_bumpiness>("bumpiness"_hs)
58 entt::attribute{"name", "bumpiness"},
59 entt::attribute{"pretty_name", "Bumpiness"},
60 entt::attribute{"min", 0.0f},
61 entt::attribute{"max", 10.0f},
62 })
63 .data<&pbr_material::set_alpha_test_value, &pbr_material::get_alpha_test_value>("alpha_test_value"_hs)
65 entt::attribute{"name", "alpha_test_value"},
66 entt::attribute{"pretty_name", "Alpha Test Value"},
67 entt::attribute{"min", 0.0f},
68 entt::attribute{"max", 1.0f},
69 })
70 .data<&pbr_material::set_tiling, &pbr_material::get_tiling>("tiling"_hs)
72 entt::attribute{"name", "tiling"},
73 entt::attribute{"pretty_name", "Tiling"}
74 })
75 .data<&pbr_material::set_dither_threshold, &pbr_material::get_dither_threshold>("dither_threshold"_hs)
77 entt::attribute{"name", "dither_threshold"},
78 entt::attribute{"pretty_name", "Dither Threshold"}
79 })
80 .data<&pbr_material::set_color_map, &pbr_material::get_color_map>("color_map"_hs)
82 entt::attribute{"name", "color_map"},
83 entt::attribute{"pretty_name", "Color Map"}
84 })
85 .data<&pbr_material::set_normal_map, &pbr_material::get_normal_map>("normal_map"_hs)
87 entt::attribute{"name", "normal_map"},
88 entt::attribute{"pretty_name", "Normal Map"}
89 })
90 .data<&pbr_material::set_roughness_map, &pbr_material::get_roughness_map>("roughness_map"_hs)
92 entt::attribute{"name", "roughness_map"},
93 entt::attribute{"pretty_name", "Roughness Map"},
94 entt::attribute{"tooltip", "Red Channel (R): Contains the roughness values.\nWhen Metalness and Roughness maps are the same.\nAs per glTF 2.0 specification:\nGreen Channel (G): Contains the roughness values.\nBlue Channel (B): Contains the metalness values."},
95 })
96 .data<&pbr_material::set_metalness_map, &pbr_material::get_metalness_map>("metalness_map"_hs)
98 entt::attribute{"name", "metalness_map"},
99 entt::attribute{"pretty_name", "Metalness Map"},
100 entt::attribute{"tooltip", "Red Channel (R): Contains the metalness values.\nWhen Metalness and Roughness maps are the same.\nAs per glTF 2.0 specification:\nGreen Channel (G): Contains the roughness values.\nBlue Channel (B): Contains the metalness values."},
101 })
102 .data<&pbr_material::set_emissive_map, &pbr_material::get_emissive_map>("emissive_map"_hs)
104 entt::attribute{"name", "emissive_map"},
105 entt::attribute{"pretty_name", "Emissive Map"},
106 entt::attribute{"tooltip", "emissive color map."}
107 })
108 .data<&pbr_material::set_ao_map, &pbr_material::get_ao_map>("ao_map"_hs)
110 entt::attribute{"name", "ao_map"},
111 entt::attribute{"pretty_name", "AO Map"},
112 entt::attribute{"tooltip", "black/white texture."}
113 });
114}
115
117{
118 try_save(ar, ser20::make_nvp("base_type", ser20::base_class<material>(&obj)));
119 try_save(ar, ser20::make_nvp("base_color", obj.base_color_));
120 try_save(ar, ser20::make_nvp("subsurface_color", obj.subsurface_color_));
121 try_save(ar, ser20::make_nvp("emissive_color", obj.emissive_color_));
122 try_save(ar, ser20::make_nvp("surface_data", obj.surface_data_));
123 try_save(ar, ser20::make_nvp("tiling", obj.tiling_));
124 try_save(ar, ser20::make_nvp("dither_threshold", obj.dither_threshold_));
125
126 try_save(ar, ser20::make_nvp("color_map", obj.color_map_));
127 try_save(ar, ser20::make_nvp("normal_map", obj.normal_map_));
128 try_save(ar, ser20::make_nvp("roughness_map", obj.roughness_map_));
129 try_save(ar, ser20::make_nvp("metalness_map", obj.metalness_map_));
130 try_save(ar, ser20::make_nvp("emissive_map", obj.emissive_map_));
131 try_save(ar, ser20::make_nvp("ao_map", obj.ao_map_));
132}
135
137{
138 try_load(ar, ser20::make_nvp("base_type", ser20::base_class<material>(&obj)));
139 try_load(ar, ser20::make_nvp("base_color", obj.base_color_));
140 try_load(ar, ser20::make_nvp("subsurface_color", obj.subsurface_color_));
141 try_load(ar, ser20::make_nvp("emissive_color", obj.emissive_color_));
142 try_load(ar, ser20::make_nvp("surface_data", obj.surface_data_));
143 try_load(ar, ser20::make_nvp("tiling", obj.tiling_));
144 try_load(ar, ser20::make_nvp("dither_threshold", obj.dither_threshold_));
145
146 try_load(ar, ser20::make_nvp("color_map", obj.color_map_));
147 try_load(ar, ser20::make_nvp("normal_map", obj.normal_map_));
148 try_load(ar, ser20::make_nvp("roughness_map", obj.roughness_map_));
149 try_load(ar, ser20::make_nvp("metalness_map", obj.metalness_map_));
150 try_load(ar, ser20::make_nvp("emissive_map", obj.emissive_map_));
151 try_load(ar, ser20::make_nvp("ao_map", obj.ao_map_));
152}
155} // namespace unravel
Class for physically-based rendering (PBR) materials.
Definition material.h:100
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
#define REFLECT(cls)
Definition reflection.h:133
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
virtual auto as_derived() -> entt::meta_any
virtual auto get_meta_type() const -> entt::meta_type