lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
material.hpp
Go to the documentation of this file.
1
12
13#pragma once
14
17
18#include <glm/glm.hpp>
19
20#include <memory>
21#include <string>
22
23namespace lmgl {
24
25namespace scene {
26
36class Material {
37 public:
46 Material(const std::string &name = "Default Material");
47
53 inline const std::string &get_name() const { return m_name; }
54
60 inline void set_name(const std::string &name) { m_name = name; }
61
67 inline const glm::vec3 &get_albedo() const { return m_albedo; }
68
74 inline void set_albedo(const glm::vec3 &albedo) { m_albedo = albedo; }
75
81 inline float get_metallic() const { return m_metallic; }
82
88 inline void set_metallic(float metallic) { m_metallic = metallic; }
89
95 inline float get_roughness() const { return m_roughness; }
96
102 inline void set_roughness(float roughness) { m_roughness = roughness; }
103
109 inline float get_ao() const { return m_ao; }
110
116 inline void set_ao(float ao) { m_ao = ao; }
117
123 inline const glm::vec3 &get_emissive() const { return m_emissive; }
124
130 inline void set_emissive(const glm::vec3 &emissive) { m_emissive = emissive; }
131
137 void set_albedo_map(const std::shared_ptr<renderer::Texture> &texture);
138
144 void set_normal_map(const std::shared_ptr<renderer::Texture> &texture);
145
151 void set_metallic_map(const std::shared_ptr<renderer::Texture> &texture);
152
158 void set_roughness_map(const std::shared_ptr<renderer::Texture> &texture);
159
165 void set_ao_map(const std::shared_ptr<renderer::Texture> &texture);
166
172 void set_emissive_map(const std::shared_ptr<renderer::Texture> &texture);
173
179 inline std::shared_ptr<renderer::Texture> get_albedo_map() const { return m_albedo_map; };
180
186 inline std::shared_ptr<renderer::Texture> get_normal_map() const { return m_normal_map; };
187
193 inline std::shared_ptr<renderer::Texture> get_metallic_map() const { return m_metallic_map; };
194
200 inline std::shared_ptr<renderer::Texture> get_roughness_map() const { return m_roughness_map; };
201
207 inline std::shared_ptr<renderer::Texture> get_ao_map() const { return m_ao_map; };
208
214 inline std::shared_ptr<renderer::Texture> get_emissive_map() const { return m_emissive_map; };
215
224 void bind(const std::shared_ptr<renderer::Shader> &shader) const;
225
226 private:
228 std::string m_name;
229
231 glm::vec3 m_albedo{1.0f, 1.0f, 1.0f};
232
234 float m_metallic{0.0f};
235
237 float m_roughness{0.5f};
238
240 float m_ao{1.0f};
241
243 glm::vec3 m_emissive{0.0f, 0.0f, 0.0f};
244
246 std::shared_ptr<renderer::Texture> m_albedo_map;
247
249 std::shared_ptr<renderer::Texture> m_normal_map;
250
252 std::shared_ptr<renderer::Texture> m_metallic_map;
253
255 std::shared_ptr<renderer::Texture> m_roughness_map;
256
258 std::shared_ptr<renderer::Texture> m_ao_map;
259
261 std::shared_ptr<renderer::Texture> m_emissive_map;
262};
263
264} // namespace scene
265
266} // namespace lmgl
void set_name(const std::string &name)
Sets the name of the material.
Definition material.hpp:60
float get_ao() const
Gets the ambient occlusion (AO) property of the material.
Definition material.hpp:109
const std::string & get_name() const
Gets the name of the material.
Definition material.hpp:53
std::shared_ptr< renderer::Texture > get_roughness_map() const
Gets the roughness texture map of the material.
Definition material.hpp:200
float get_roughness() const
Gets the roughness property of the material.
Definition material.hpp:95
const glm::vec3 & get_albedo() const
Gets the albedo color of the material.
Definition material.hpp:67
void set_roughness_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the roughness texture map of the material.
Definition material.cpp:15
std::shared_ptr< renderer::Texture > get_albedo_map() const
Gets the albedo texture map of the material.
Definition material.hpp:179
void set_metallic(float metallic)
Sets the metallic property of the material.
Definition material.hpp:88
std::shared_ptr< renderer::Texture > get_metallic_map() const
Gets the metallic texture map of the material.
Definition material.hpp:193
std::shared_ptr< renderer::Texture > get_normal_map() const
Gets the normal texture map of the material.
Definition material.hpp:186
float get_metallic() const
Gets the metallic property of the material.
Definition material.hpp:81
void set_emissive_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the emissive texture map of the material.
Definition material.cpp:19
void set_normal_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the normal texture map of the material.
Definition material.cpp:11
const glm::vec3 & get_emissive() const
Gets the emissive color of the material.
Definition material.hpp:123
void set_ao_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the ambient occlusion (AO) texture map of the material.
Definition material.cpp:17
Material(const std::string &name="Default Material")
Constructs a Material with an optional name.
Definition material.cpp:7
void bind(const std::shared_ptr< renderer::Shader > &shader) const
Binds the material properties and textures to the given shader.
Definition material.cpp:21
void set_ao(float ao)
Sets the ambient occlusion (AO) property of the material.
Definition material.hpp:116
void set_albedo_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the albedo texture map of the material.
Definition material.cpp:9
std::shared_ptr< renderer::Texture > get_emissive_map() const
Gets the emissive texture map of the material.
Definition material.hpp:214
void set_roughness(float roughness)
Sets the roughness property of the material.
Definition material.hpp:102
std::shared_ptr< renderer::Texture > get_ao_map() const
Gets the ambient occlusion (AO) texture map of the material.
Definition material.hpp:207
void set_emissive(const glm::vec3 &emissive)
Sets the emissive color of the material.
Definition material.hpp:130
void set_metallic_map(const std::shared_ptr< renderer::Texture > &texture)
Sets the metallic texture map of the material.
Definition material.cpp:13
void set_albedo(const glm::vec3 &albedo)
Sets the albedo color of the material.
Definition material.hpp:74
Namespace for scene-related classes and functions.
Definition camera.cpp:7
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Declaration of the Shader class for managing shader programs in OpenGL.
Texture class for managing OpenGL textures.