Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
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
12namespace Grindstone {
13 class EngineCore;
14
15 namespace Editor {
16 namespace ImguiEditor {
17 class ImguiEditor;
18
19 struct Sampler {
20 std::string name;
21 Uuid value;
22 std::string valueName;
23 bool isSet;
24
25 Sampler(const char* samplerName) : name(samplerName), isSet(false) {}
26 };
27
29 std::string path;
30 };
31
33 public:
34 MaterialInspector(EngineCore* engineCore, ImguiEditor* imguiEditor);
35 void SetMaterialPath(const std::filesystem::path& materialPath);
36 void Render();
37 private:
38 enum class ShaderLoadStatus {
39 Unassigned = 0,
40 InvalidPath,
41 NoFileFound,
42 InvalidShader,
43 ValidShader
44 };
45 void ReloadAvailableShaders();
46 bool TryLoadShaderReflection(Uuid& shaderUuid);
47 void LoadShaderTextures(rapidjson::Value& texturesArray);
48 void LoadShaderUniformBuffers(rapidjson::Value& uniformBuffers);
49 void LoadMaterialSamplers(rapidjson::Value& samplers);
50 void RenderTextures();
51 void RenderParameters();
52 void OnSelectedTexture(Uuid uuid, std::string name);
53 void RenderTexture(Sampler& sampler);
54 void RenderParameter(MaterialParameter& parameter);
55 void SaveMaterial();
56 std::filesystem::path materialPath;
57 std::string filename;
58 std::string materialName;
59 Uuid shaderUuid;
60 std::string shaderName;
61 std::vector<Sampler> samplers;
62 std::vector<MaterialParameter> parameters;
63 std::vector<AssetRegistry::Entry> availableShaders;
64 EngineCore* engineCore;
65 ImguiEditor* imguiEditor = nullptr;
66 Sampler* selectedSampler = nullptr;
67 ShaderLoadStatus shaderLoadStatus = ShaderLoadStatus::Unassigned;
68 bool hasBeenChanged = false;
69
70 struct MaterialUniformBuffer {
71 struct Member {
72 std::string name;
73 size_t offset = 0;
74 size_t memberSize = 0;
75 Member() = default;
76 Member(
77 std::string name,
78 size_t offset,
79 size_t memberSize
80 ) : name(name), offset(offset), memberSize(memberSize) {}
81 };
82 std::string name;
83 size_t bindingId = 0;
84 size_t bufferSize = 0;
85 std::vector<Member> members;
86 MaterialUniformBuffer() = default;
87 MaterialUniformBuffer(
88 std::string name,
89 size_t bindingId,
90 size_t bufferSize
91 ) : name(name), bindingId(bindingId), bufferSize(bufferSize) {}
92 };
93
94 std::vector<MaterialUniformBuffer> materialUniformBuffers;
95 };
96 }
97 }
98}
Definition MaterialInspector.hpp:32
Definition EngineCore.hpp:57
Definition Uuid.hpp:6
Definition MaterialInspector.hpp:28
Definition MaterialInspector.hpp:19