Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Toggle main menu visibility
Loading...
Searching...
No Matches
MaterialInspector.hpp
1
#pragma once
2
3
#include <filesystem>
4
#include <string>
5
#include <vector>
6
7
#include <rapidjson/document.h>
8
9
#include <Common/ResourcePipeline/Uuid.hpp>
10
#include <Editor/AssetRegistry.hpp>
11
#include <EngineCore/Assets/AssetReference.hpp>
12
#include <EngineCore/Assets/Textures/TextureAsset.hpp>
13
14
namespace
Grindstone {
15
class
EngineCore
;
16
17
namespace
GraphicsAPI {
18
class
DescriptorSet
;
19
class
DescriptorSetLayout
;
20
}
21
22
namespace
Editor {
23
namespace
ImguiEditor {
24
class
ImguiEditor
;
25
26
struct
Sampler {
27
std::string name;
28
std::string value;
29
std::string valueName;
30
bool
isSet;
31
Grindstone::AssetReference<Grindstone::TextureAsset>
textureReference;
32
GraphicsAPI::DescriptorSet
* textureDescriptorSet =
nullptr
;
33
34
Sampler(
const
char
* samplerName) : name(samplerName), isSet(
false
) {}
35
};
36
37
struct
MaterialParameter
{
38
std::string path;
39
};
40
41
class
MaterialInspector {
42
public
:
43
MaterialInspector(
EngineCore
* engineCore,
ImguiEditor
* imguiEditor);
44
void
SetMaterialPath(
const
std::filesystem::path& materialPath);
45
void
Render();
46
private
:
47
enum class
ShaderLoadStatus {
48
Unassigned = 0,
49
InvalidPath,
50
NoFileFound,
51
InvalidShader,
52
ValidShader
53
};
54
void
ReloadAvailablePipelineSets();
55
bool
TryLoadShaderReflection(
Uuid
& shaderUuid);
56
void
LoadShaderUniformBuffers(rapidjson::Value& uniformBuffers);
57
void
LoadMaterialSamplers(rapidjson::Value& samplers);
58
void
RenderTextures();
59
void
RenderParameters();
60
void
OnSelectedTexture(
Uuid
uuid, std::string name);
61
void
RenderTexture(
Sampler
& sampler);
62
void
RenderParameter(
MaterialParameter
& parameter);
63
void
SaveMaterial();
64
std::filesystem::path materialPath;
65
std::string filename;
66
std::string materialName;
67
Uuid
shaderUuid;
68
std::string pipelineSetName;
69
std::vector<Sampler> pipelineSetSamplers;
70
std::vector<MaterialParameter> parameters;
71
Grindstone::GraphicsAPI::DescriptorSetLayout
* textureDisplayDescriptorSetLayout =
nullptr
;
72
Grindstone::GraphicsAPI::Image
* missingImage =
nullptr
;
73
Grindstone::GraphicsAPI::DescriptorSet
* missingImageDescriptorSet =
nullptr
;
74
std::vector<AssetRegistry::Entry> availablePipelineSets;
75
EngineCore
* engineCore;
76
ImguiEditor
* imguiEditor =
nullptr
;
77
Sampler
* selectedSampler =
nullptr
;
78
ShaderLoadStatus shaderLoadStatus = ShaderLoadStatus::Unassigned;
79
bool
hasBeenChanged =
false
;
80
81
struct
MaterialUniformBuffer {
82
struct
Member {
83
std::string name;
84
size_t
offset = 0;
85
size_t
memberSize = 0;
86
Member() =
default
;
87
Member(
88
std::string name,
89
size_t
offset,
90
size_t
memberSize
91
) : name(name), offset(offset), memberSize(memberSize) {}
92
};
93
std::string name;
94
size_t
bindingId = 0;
95
size_t
bufferSize = 0;
96
std::vector<Member> members;
97
MaterialUniformBuffer() =
default
;
98
MaterialUniformBuffer(
99
std::string name,
100
size_t
bindingId,
101
size_t
bufferSize
102
) : name(name), bindingId(bindingId), bufferSize(bufferSize) {}
103
};
104
105
std::vector<MaterialUniformBuffer> materialUniformBuffers;
106
};
107
}
108
}
109
}
Grindstone::Editor::ImguiEditor::ImguiEditor
Definition
ImguiEditor.hpp:52
Grindstone::EngineCore
Definition
EngineCore.hpp:59
Grindstone::GraphicsAPI::DescriptorSetLayout
Definition
DescriptorSetLayout.hpp:14
Grindstone::GraphicsAPI::DescriptorSet
Definition
DescriptorSet.hpp:15
Grindstone::GraphicsAPI::Image
Definition
Image.hpp:49
Grindstone::Uuid
Definition
Uuid.hpp:7
Grindstone::AssetReference
Definition
AssetReference.hpp:45
Grindstone::Editor::ImguiEditor::MaterialParameter
Definition
MaterialInspector.hpp:37
Grindstone::Editor::ImguiEditor::Sampler
Definition
MaterialInspector.hpp:26
sources
code
Editor
ImguiEditor
MaterialInspector.hpp
Generated by
1.17.0