Raftel Engine
 
Loading...
Searching...
No Matches
material.hpp
Go to the documentation of this file.
1
24
25#ifndef __MATERIAL_H__
26#define __MATERIAL_H__ 1
27
28#pragma once
29
30#include <glm/glm.hpp>
31#include <memory>
32#include <unordered_map>
33#include <string>
34#include <iostream>
35#include <stdexcept>
36#include <raftel/texture.hpp>
37
38namespace Raftel {
43 class Material {
44 public:
45
46 //TODO mapa de texturas -> KEY (enum de cada textura) valor -> TEXTURE
47
52
67 std::shared_ptr<Texture> albedo,
68 std::shared_ptr<Texture> normal = nullptr,
69 std::shared_ptr<Texture> roughness = nullptr,
70 std::shared_ptr<Texture> metallic = nullptr,
71 const glm::vec3& albedoColor = glm::vec3(1.0f),
72 float shininess = 32.0f,
73 float roughnessValue = 0.5f,
74 float metallicValue = 0.0f,
75 float fresnel = 1.0f,
76 float scatt = 0.0f
77 );
78
79
84 void setAlbedo(std::shared_ptr<Texture> texture);
85
90 void setNormal(std::shared_ptr<Texture> texture);
91
96 void setRoughness(std::shared_ptr<Texture> texture);
97
102 void setMetallic(std::shared_ptr<Texture> texture);
103
108
113
118
123
128 std::shared_ptr<Texture> getAlbedoText();
129
134 std::shared_ptr<Texture> getNormalText();
135
140 std::shared_ptr<Texture> getRoughnessText();
141
146 std::shared_ptr<Texture> getMetallicText();
147
152 glm::vec3 getAlbedoColor() { return albedoColor; }
153
158 float getShininessValue() { return shininess; }
159
164 float getRoughnessValue() { return roughnessValue; }
165
170 float getMetallicValue() { return metallicValue; }
171
176 float getFresnelValue() { return fresnel; }
177
182 float getScatteringValue() { return scattering; }
183
188 void setAlbedoColor(const glm::vec3& color);
189
194 void setShininess(float value);
195
200 void setRoughness(float value);
201
206 void setMetallic(float value);
207
212 void setFresnel(float value);
213
218 void setScattering(float value);
219
224 int GetNTextures() { return texture_counter; }
225
226 //int texture_counter = 0; ///< Number of active textures.
227
228 bool bAlbedo;
229 bool bNormal;
232
237 const std::string& getLastError() const { return lastError; }
238
244 MOVABLE_BUT_NOT_COPYABLE(Material)
245 private:
246 std::shared_ptr<Texture> albedo;
247 std::shared_ptr<Texture> normal;
248 std::shared_ptr<Texture> roughness;
249 std::shared_ptr<Texture> metallic;
250
251 glm::vec3 albedoColor;
252 float shininess;
253 float roughnessValue;
254 float metallicValue;
255 float fresnel;
256 float scattering;
257
258 int texture_counter = 0;
259
266 void setError(const std::string& errorMessage, const char* file, int line);
267 std::string lastError;
268 };
269}// namespace Raftel
270
271#endif // __MATERIAL_HPP__
Represents a material with textures and physical properties.
Definition material.hpp:43
void deleteMetallic()
Remove the metallic texture.
bool bNormal
True if a normal texture is assigned.
Definition material.hpp:229
std::shared_ptr< Texture > getAlbedoText()
Get the albedo (diffuse) texture.
void setRoughness(float value)
Set the roughness value of the material.
bool bRoughness
True if a roughness texture is assigned.
Definition material.hpp:230
void setAlbedo(std::shared_ptr< Texture > texture)
Set the albedo (diffuse) texture of the material.
bool bMetallic
True if a metallic texture is assigned.
Definition material.hpp:231
void deleteRoughness()
Remove the roughness texture.
bool bAlbedo
True if an albedo texture is assigned.
Definition material.hpp:228
std::shared_ptr< Texture > getNormalText()
Get the normal map texture.
std::shared_ptr< Texture > getMetallicText()
Get the metallic texture.
void deleteNormal()
Remove the normal texture.
void setFresnel(float value)
Set the fresnel value of the material.
const std::string & getLastError() const
Retrieves the last recorded error message.
Definition material.hpp:237
float getRoughnessValue()
Get the roughness value of the material.
Definition material.hpp:164
void deleteAlbedo()
Remove the albedo texture.
Material(std::shared_ptr< Texture > albedo, std::shared_ptr< Texture > normal=nullptr, std::shared_ptr< Texture > roughness=nullptr, std::shared_ptr< Texture > metallic=nullptr, const glm::vec3 &albedoColor=glm::vec3(1.0f), float shininess=32.0f, float roughnessValue=0.5f, float metallicValue=0.0f, float fresnel=1.0f, float scatt=0.0f)
Constructs a Material with textures and properties.
int GetNTextures()
Get the number of active textures assigned to the material.
Definition material.hpp:224
void setScattering(float value)
Set the scattering value of the material.
float getFresnelValue()
Get the fresnel value of the material.
Definition material.hpp:176
glm::vec3 getAlbedoColor()
Get the albedo color (used when no albedo texture is provided).
Definition material.hpp:152
float getMetallicValue()
Get the metallic value of the material.
Definition material.hpp:170
void setMetallic(std::shared_ptr< Texture > texture)
Set the metallic texture of the material.
void setMetallic(float value)
Set the metallic value of the material.
void setRoughness(std::shared_ptr< Texture > texture)
Set the roughness texture of the material.
void setAlbedoColor(const glm::vec3 &color)
Set the albedo color (used when no albedo texture is provided).
Material()
Default constructor initializes a basic white material with no textures.
float getScatteringValue()
Get the scattering value of the material.
Definition material.hpp:182
void setShininess(float value)
Set the shininess value of the material.
float getShininessValue()
Get the shininess value of the material.
Definition material.hpp:158
std::shared_ptr< Texture > getRoughnessText()
Get the roughness texture.
void setNormal(std::shared_ptr< Texture > texture)
Set the normal map texture of the material.
Contains the definitions for the TextureImage and Texture classes.