NoJobEngine 2.0.7
Loading...
Searching...
No Matches
Material.h
Go to the documentation of this file.
1
6#pragma once
7#include <glm/glm.hpp>
8#include <memory>
9
10namespace NoJob
11{
12 class Shader;
13 class Texture2D;
14
16 {
17 Opaque = 0,
20 };
21
23 {
24 public:
25 Material(std::shared_ptr<Shader> shader,
26 const glm::vec4& color = glm::vec4(1.0f));
27
28 const std::shared_ptr<Shader>& GetShader() const { return m_Shader; }
29 glm::vec4& GetColor() { return m_Color; }
30 const glm::vec4& GetColor() const { return m_Color; }
31
32 void SetTexture(std::shared_ptr<Texture2D> texture)
33 {
34 m_Texture = std::move(texture);
35 }
36
37 const std::shared_ptr<Texture2D>& GetTexture() const
38 {
39 return m_Texture;
40 }
41
42 bool& UseTexture() { return m_UseTexture; }
43
44 bool IsUsingTexture() const
45 {
46 return m_UseTexture && m_Texture != nullptr;
47 }
48
49 float& Metallic() { return m_Metallic; }
50 float& Roughness() { return m_Roughness; }
51 float& AmbientOcclusion() { return m_AmbientOcclusion; }
52 float& NormalStrength() { return m_NormalStrength; }
53 glm::vec3& EmissiveColor() { return m_EmissiveColor; }
54 float& EmissiveStrength() { return m_EmissiveStrength; }
55 const float& Metallic() const { return m_Metallic; }
56 const float& Roughness() const { return m_Roughness; }
57 const float& AmbientOcclusion() const { return m_AmbientOcclusion; }
58
59 void SetNormalTexture(std::shared_ptr<Texture2D> v) { m_NormalTexture = std::move(v); }
60 void SetMetallicTexture(std::shared_ptr<Texture2D> v) { m_MetallicTexture = std::move(v); }
61 void SetRoughnessTexture(std::shared_ptr<Texture2D> v) { m_RoughnessTexture = std::move(v); }
62 void SetAOTexture(std::shared_ptr<Texture2D> v) { m_AOTexture = std::move(v); }
63 void SetEmissiveTexture(std::shared_ptr<Texture2D> v) { m_EmissiveTexture = std::move(v); }
64 const std::shared_ptr<Texture2D>& GetNormalTexture() const { return m_NormalTexture; }
65 const std::shared_ptr<Texture2D>& GetMetallicTexture() const { return m_MetallicTexture; }
66 const std::shared_ptr<Texture2D>& GetRoughnessTexture() const { return m_RoughnessTexture; }
67 const std::shared_ptr<Texture2D>& GetAOTexture() const { return m_AOTexture; }
68 const std::shared_ptr<Texture2D>& GetEmissiveTexture() const { return m_EmissiveTexture; }
69
70 MaterialSurfaceMode& SurfaceMode() { return m_SurfaceMode; }
71 MaterialSurfaceMode SurfaceMode() const { return m_SurfaceMode; }
72 float& AlphaCutoff() { return m_AlphaCutoff; }
73 float AlphaCutoff() const { return m_AlphaCutoff; }
74
75 private:
76 std::shared_ptr<Shader> m_Shader;
77 glm::vec4 m_Color{ 1.0f };
78 std::shared_ptr<Texture2D> m_Texture;
79 bool m_UseTexture = true;
80 float m_Metallic = 0.0f;
81 float m_Roughness = 0.5f;
82 float m_AmbientOcclusion = 1.0f;
83 float m_NormalStrength = 1.0f;
84 glm::vec3 m_EmissiveColor{ 0.0f };
85 float m_EmissiveStrength = 0.0f;
86 std::shared_ptr<Texture2D> m_NormalTexture;
87 std::shared_ptr<Texture2D> m_MetallicTexture;
88 std::shared_ptr<Texture2D> m_RoughnessTexture;
89 std::shared_ptr<Texture2D> m_AOTexture;
90 std::shared_ptr<Texture2D> m_EmissiveTexture;
92 float m_AlphaCutoff = 0.5f;
93 };
94}
void SetMetallicTexture(std::shared_ptr< Texture2D > v)
Definition Material.h:60
glm::vec3 & EmissiveColor()
Definition Material.h:53
float & Metallic()
Definition Material.h:49
void SetNormalTexture(std::shared_ptr< Texture2D > v)
Definition Material.h:59
void SetRoughnessTexture(std::shared_ptr< Texture2D > v)
Definition Material.h:61
bool & UseTexture()
Definition Material.h:42
const std::shared_ptr< Texture2D > & GetAOTexture() const
Definition Material.h:67
void SetEmissiveTexture(std::shared_ptr< Texture2D > v)
Definition Material.h:63
const float & AmbientOcclusion() const
Definition Material.h:57
void SetAOTexture(std::shared_ptr< Texture2D > v)
Definition Material.h:62
const std::shared_ptr< Texture2D > & GetNormalTexture() const
Definition Material.h:64
bool IsUsingTexture() const
Definition Material.h:44
float & AmbientOcclusion()
Definition Material.h:51
const std::shared_ptr< Texture2D > & GetMetallicTexture() const
Definition Material.h:65
float & Roughness()
Definition Material.h:50
const float & Roughness() const
Definition Material.h:56
const std::shared_ptr< Texture2D > & GetEmissiveTexture() const
Definition Material.h:68
const float & Metallic() const
Definition Material.h:55
Material(std::shared_ptr< Shader > shader, const glm::vec4 &color=glm::vec4(1.0f))
Definition Material.cpp:6
const std::shared_ptr< Texture2D > & GetTexture() const
Definition Material.h:37
const std::shared_ptr< Texture2D > & GetRoughnessTexture() const
Definition Material.h:66
const glm::vec4 & GetColor() const
Definition Material.h:30
void SetTexture(std::shared_ptr< Texture2D > texture)
Definition Material.h:32
glm::vec4 & GetColor()
Definition Material.h:29
float AlphaCutoff() const
Definition Material.h:73
float & AlphaCutoff()
Definition Material.h:72
MaterialSurfaceMode & SurfaceMode()
Definition Material.h:70
MaterialSurfaceMode SurfaceMode() const
Definition Material.h:71
const std::shared_ptr< Shader > & GetShader() const
Definition Material.h:28
float & NormalStrength()
Definition Material.h:52
float & EmissiveStrength()
Definition Material.h:54
MaterialSurfaceMode
Definition Material.h:16