-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaterialBuilder.h
More file actions
89 lines (63 loc) · 2.51 KB
/
MaterialBuilder.h
File metadata and controls
89 lines (63 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include"Material.h"
#include"TextureFactory.h"
class MaterialBuilder : public std::enable_shared_from_this<MaterialBuilder>
{
private:
//ファクトリークラス
std::shared_ptr<GpuBufferFactory> bufferFactory;
std::shared_ptr<DescriptorSetLayoutFactory> layoutFactory;
std::shared_ptr<DescriptorSetFactory> descriptorSetFactory;
std::shared_ptr<TextureFactory> textureFactory;
std::shared_ptr<Texture> emptyTexture;
MaterialProperty property;
void createEmptyTexture();
public:
MaterialBuilder(std::shared_ptr<GpuBufferFactory> buffer,
std::shared_ptr<DescriptorSetLayoutFactory> layout,
std::shared_ptr<DescriptorSetFactory> desc
, std::shared_ptr<TextureFactory> texture)
{
bufferFactory = buffer;
layoutFactory = layout;
descriptorSetFactory = desc;
textureFactory = texture;
property.initProperty();
//ダミーテクスチャを作る
createEmptyTexture();
}
~MaterialBuilder()
{
#ifdef _DEBUG
std::cout << "MaterialBuilder :: デストラクタ" << std::endl;
#endif
}
//マテリアルのプロパティを初期化
std::shared_ptr<MaterialBuilder> initProperty();
//基本色のテクスチャを設定
std::shared_ptr<MaterialBuilder> withBaseColorTexture(const int& uvIndex,std::shared_ptr<Texture> texture);
//メタリックと粗さのテクスチャを設定
std::shared_ptr<MaterialBuilder> withMetallicRoughnessTexture(const int& uvIndex, std::shared_ptr<Texture> texture);
//法線用テクスチャを設定
std::shared_ptr<MaterialBuilder> withNormalTexture(const int& uvIndex, std::shared_ptr<Texture> texture);
//オクルージョン化リング用テクスチャを設定
std::shared_ptr<MaterialBuilder> withOcclusionTexture(const int& uvIndex, std::shared_ptr<Texture> texture);
//発光用テクスチャを設定
std::shared_ptr<MaterialBuilder> withEmissiveTexture(const int& uvIndex, std::shared_ptr<Texture> texture);
//基本色の設定
std::shared_ptr<MaterialBuilder> withBaseColorFactor(const glm::vec4& factor);
//発光の設定
std::shared_ptr<MaterialBuilder> withEmissiveFactor(const glm::vec4& factor);
//金属光沢の度合いを設定
std::shared_ptr<MaterialBuilder> withMetallicFactor(const float& factor);
//粗さの度合いを設定
std::shared_ptr<MaterialBuilder> withRoughnessFactor(const float& factor);
//透明度の最大値を設定
std::shared_ptr<MaterialBuilder> withAlphaMaskCutOff(const float& cutoff);
//自己放射の強さを設定
std::shared_ptr<MaterialBuilder> withEmissiveStrength(const float& strength);
//マテリアルのプロパティを作成
MaterialProperty Build();
//マテリアルを作成
std::shared_ptr<Material> Create(const MaterialProperty& property);
};