Scripting changes for item and added level 1 scene #330

Merged
glencelow merged 10 commits from PlayerController into main 2023-02-02 11:20:20 +08:00
29 changed files with 530 additions and 76 deletions
Showing only changes of commit ec11f8cb8f - Show all commits

2
.gitignore vendored
View File

@ -363,8 +363,6 @@ MigrationBackup/
*.filters *.filters
Assets/Editor/Layouts/UserLayout.ini
JSON/Schemas/Catalog/ JSON/Schemas/Catalog/
Assets/Editor/Editor.SHConfig Assets/Editor/Editor.SHConfig

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false Start in Fullscreen: false
Starting Scene ID: 87244611 Starting Scene ID: 97158628
Window Size: {x: 1920, y: 1080} Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine Window Title: SHADE Engine

View File

@ -1,4 +0,0 @@
Start Maximized: true
Working Scene ID: 97402985
Window Size: {x: 1920, y: 1013}
Style: 0

View File

@ -0,0 +1,165 @@
[Window][MainStatusBar]
Pos=0,989
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=1920,941
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,187
Size=300,802
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1604,48
Size=316,941
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=300,137
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌð‡Žoû]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ]
Pos=60,60
Size=999,581
Collapsed=0
[Window][ð‡]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌ]
Pos=60,60
Size=553,422
Collapsed=0
[Window][]
Pos=60,60
Size=770,394
Collapsed=0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][î<> Viewport]
Pos=302,48
Size=1300,836
Collapsed=0
DockId=0x0000000B,0
[Window][V]
Pos=310,722
Size=1501,338
Collapsed=0
DockId=0x00000008,0
[Window][p£€Ê]
Pos=310,750
Size=1501,310
Collapsed=0
DockId=0x0000000A,0
[Window][ Asset Browser]
Pos=302,886
Size=1300,103
Collapsed=0
DockId=0x0000000C,0
[Window][Material Inspector]
Pos=1604,48
Size=316,941
Collapsed=0
DockId=0x00000006,1
[Window][Save scene as...]
Pos=1197,693
Size=165,120
Collapsed=0
[Window][Create New Asset]
Pos=896,472
Size=464,144
Collapsed=0
[Window][Collider Tag Panel]
Pos=60,60
Size=625,744
Collapsed=0
[Window][Input Bindings Panel]
Pos=60,60
Size=154,204
Collapsed=0
[Window][Save Scene As]
Pos=877,444
Size=165,120
Collapsed=0
[Table][0x9D40AE32,17]
Column 0 Weight=1.0000
Column 1 Weight=1.0000
Column 2 Weight=1.0000
Column 3 Weight=1.0000
Column 4 Weight=1.0000
Column 5 Weight=1.0000
Column 6 Weight=1.0000
Column 7 Weight=1.0000
Column 8 Weight=1.0000
Column 9 Weight=1.0000
Column 10 Weight=1.0000
Column 11 Weight=1.0000
Column 12 Weight=1.0000
Column 13 Weight=1.0000
Column 14 Weight=1.0000
Column 15 Weight=1.0000
Column 16 Weight=1.0000
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1602,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1300,1036 Split=Y Selected=0xB41284E7
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,836 CentralNode=1 Selected=0xB41284E7
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,103 Selected=0xB128252A
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=316,1036 Selected=0xE7039252

View File

@ -1,6 +1,6 @@
- VertexShader: 46580970 - VertexShader: 46580970
FragmentShader: 35983630 FragmentShader: 35983630
SubPass: G-Buffer Write SubPass: UI
Properties: Properties:
data.color: {x: 1, y: 1, z: 1, w: 1} data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 54324293 data.textureIndex: 54324293

View File

@ -1,6 +1,6 @@
- VertexShader: 46580970 - VertexShader: 46580970
FragmentShader: 35983630 FragmentShader: 35983630
SubPass: G-Buffer Write SubPass: UI
Properties: Properties:
data.color: {x: 1, y: 1, z: 1, w: 1} data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 54429632 data.textureIndex: 54429632

View File

@ -1,6 +1,6 @@
- VertexShader: 46580970 - VertexShader: 46580970
FragmentShader: 35983630 FragmentShader: 35983630
SubPass: G-Buffer Write SubPass: UI
Properties: Properties:
data.color: {x: 1, y: 1, z: 1, w: 1} data.color: {x: 1, y: 1, z: 1, w: 1}
data.textureIndex: 57302694 data.textureIndex: 57302694

View File

@ -33,18 +33,11 @@ layout (std430, set = 2, binding = 0) buffer MaterialProperties // For mater
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;
layout(location = 0) out vec4 position; layout(location = 0) out vec4 fragColor;
layout(location = 1) out uint outEntityID; layout(location = 1) out uint outEntityID;
layout(location = 2) out uint lightLayerIndices;
layout(location = 3) out vec4 normals;
layout(location = 4) out vec4 albedo;
void main() void main()
{ {
position = In.vertPos; fragColor = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
normals = In.normal;
albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv);
outEntityID = In2.eid; outEntityID = In2.eid;
lightLayerIndices = In2.lightLayerIndex;
} }

Binary file not shown.

View File

@ -27,6 +27,7 @@
#include "Libraries/Compilers/SHShaderSourceCompiler.h" #include "Libraries/Compilers/SHShaderSourceCompiler.h"
#include "Filesystem/SHFileSystem.h" #include "Filesystem/SHFileSystem.h"
#include <rttr/registration.h>
namespace SHADE namespace SHADE
{ {
@ -733,3 +734,25 @@ namespace SHADE
} }
} }
} }
namespace rttr
{
using namespace SHADE;
RTTR_REGISTRATION
{
registration::enumeration<AssetType>("Asset Type")
(
value("Invalid", AssetType::INVALID),
value("Shader", AssetType::SHADER),
value("Shader [Built-In]", AssetType::SHADER_BUILT_IN),
value("Texture", AssetType::TEXTURE),
value("Model", AssetType::MODEL),
value("Scene", AssetType::SCENE),
value("Prefab", AssetType::PREFAB),
value("Material", AssetType::MATERIAL),
value("Mesh", AssetType::MESH),
value("Script", AssetType::SCRIPT),
value("Font", AssetType::FONT)
);
}
}

View File

@ -314,7 +314,7 @@ namespace SHADE
camera.orthoProjMatrix(3, 3) = 1.0f; camera.orthoProjMatrix(3, 3) = 1.0f;
//camera.perspProjMatrix = SHMatrix::OrthographicLH(9.0f, 9.0f, 0.1f, 20.0f); //camera.perspProjMatrix = SHMatrix::OrthographicLH(9.0f, 9.0f, 0.1f, 20.0f);
camera.orthoProjMatrix = SHMatrix::OrthographicRH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar()); //camera.orthoProjMatrix = SHMatrix::OrthographicLH(camera.GetWidth(), camera.GetHeight(), camera.GetNear(), camera.GetFar());
//camera.perspProjMatrix = SHMatrix::OrthographicLH(5.0f, 5.0f, 0.1f, 20.0f); //camera.perspProjMatrix = SHMatrix::OrthographicLH(5.0f, 5.0f, 0.1f, 20.0f);
//camera.projMatrix.Transpose(); //camera.projMatrix.Transpose();

View File

@ -16,6 +16,9 @@
#include "Editor/EditorWindow/SHEditorWindowManager.h" #include "Editor/EditorWindow/SHEditorWindowManager.h"
#include "Scripting/SHVSUtilities.h" #include "Scripting/SHVSUtilities.h"
#include "Scripting/SHScriptEngine.h" #include "Scripting/SHScriptEngine.h"
#include "Tools/Utilities/SHStringUtilities.h"
#include <filesystem>
#include <rttr/type>
namespace SHADE namespace SHADE
{ {
@ -27,6 +30,13 @@ namespace SHADE
void SHAssetBrowser::Init() void SHAssetBrowser::Init()
{ {
SHEditorWindow::Init(); SHEditorWindow::Init();
rttr::array_range<rttr::string_view> typeNames = typeEnumAlign.get_names();
for(auto const& name : typeNames)
{
uint64_t val = typeEnumAlign.name_to_value(name).to_uint64();
typeFilters[val] = true;
}
} }
void SHAssetBrowser::Update() void SHAssetBrowser::Update()
@ -34,7 +44,10 @@ namespace SHADE
SHEditorWindow::Update(); SHEditorWindow::Update();
if (Begin()) if (Begin())
{ {
RecursivelyDrawTree(rootFolder); for(auto subFolder : rootFolder->subFolders)
{
RecursivelyDrawTree(subFolder);
}
DrawMenuBar(); DrawMenuBar();
DrawCurrentFolder(); DrawCurrentFolder();
DrawAssetBeingCreated(); DrawAssetBeingCreated();
@ -50,6 +63,11 @@ namespace SHADE
refreshQueued = true; refreshQueued = true;
} }
void SHAssetBrowser::SetScrollTo(AssetID assetid)
{
assetToScrollTo = assetid;
}
void SHAssetBrowser::Refresh() noexcept void SHAssetBrowser::Refresh() noexcept
{ {
SHAssetManager::RefreshDirectory(); SHAssetManager::RefreshDirectory();
@ -69,6 +87,7 @@ namespace SHADE
{ {
isAssetBeingCreated = true; isAssetBeingCreated = true;
} }
DrawAssetBrowserFilter();
ImGui::EndMenuBar(); ImGui::EndMenuBar();
} }
} }
@ -81,13 +100,34 @@ namespace SHADE
auto files = folder->files; auto files = folder->files;
const bool isSelected = std::ranges::find(selectedFolders, folder) != selectedFolders.end(); const bool isSelected = std::ranges::find(selectedFolders, folder) != selectedFolders.end();
ImGuiTreeNodeFlags flags = (subFolders.empty() && files.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow; ImGuiTreeNodeFlags flags = (subFolders.empty() && files.empty()) ? ImGuiTreeNodeFlags_Leaf : ImGuiTreeNodeFlags_OpenOnArrow;
if(!filter.empty() && (!subFolders.empty() || !files.empty()))
{
ImGui::SetNextItemOpen(true);
}
if (isSelected) if (isSelected)
flags |= ImGuiTreeNodeFlags_Selected; flags |= ImGuiTreeNodeFlags_Selected;
if (folder == rootFolder) if (folder == rootFolder)
flags |= ImGuiTreeNodeFlags_DefaultOpen; flags |= ImGuiTreeNodeFlags_DefaultOpen;
bool isOpen = ImGui::TreeNodeEx(folder, flags, "%s %s", ICON_MD_FOLDER, folder->name.data()); if(assetToScrollTo != 0)
ImGuiID folderID = ImGui::GetItemID(); {
if(auto asset = SHAssetManager::GetAsset(assetToScrollTo))
{
if(!asset->path.empty())
{
ImGui::SetNextItemOpen(SHStringUtilities::StringFindInsensitive(asset->path.string(), folder->name.data()) != std::string::npos);
}
else if(auto parent = SHAssetManager::GetAsset(asset->parent))
{
ImGui::SetNextItemOpen(SHStringUtilities::StringFindInsensitive(parent->path.string(), folder->name.data()) != std::string::npos);
}
}
}
bool isOpen = false;
if(filter.empty())
isOpen = ImGui::TreeNodeEx(folder, flags, "%s %s", ICON_MD_FOLDER, folder->name.data());
const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
//if (ImGui::BeginPopupContextItem()) //if (ImGui::BeginPopupContextItem())
@ -101,7 +141,7 @@ namespace SHADE
selectedFolders.push_back(folder); selectedFolders.push_back(folder);
} }
if (isOpen) if (isOpen || !filter.empty())
{ {
const ImColor treeLineColor = ImGui::GetColorU32(ImGuiCol_CheckMark); const ImColor treeLineColor = ImGui::GetColorU32(ImGuiCol_CheckMark);
const float horizontalOffset = 0.0f; const float horizontalOffset = 0.0f;
@ -127,6 +167,7 @@ namespace SHADE
} }
drawList->AddLine(vertLineStart, vertLineEnd, treeLineColor, 1); drawList->AddLine(vertLineStart, vertLineEnd, treeLineColor, 1);
if(filter.empty())
ImGui::TreePop(); ImGui::TreePop();
} }
return nodeRect; return nodeRect;
@ -167,8 +208,26 @@ namespace SHADE
{ {
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf; ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf;
static constexpr std::string_view icon = ICON_MD_FILE_PRESENT; static constexpr std::string_view icon = ICON_MD_FILE_PRESENT;
bool highlighted = false;
if (!filter.empty())
{
if (SHStringUtilities::StringFindInsensitive(file.name.data(), filter) == std::string::npos)
{
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
}
else
{
highlighted = true;
ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor);
}
}
ImGui::PushID(file.name.data()); ImGui::PushID(file.name.data());
bool const isOpen = ImGui::TreeNodeEx(file.name.data(), flags, "%s %s%s", icon.data(), file.name.data(), file.ext.data()); bool const isOpen = ImGui::TreeNodeEx(file.name.data(), flags, "%s %s%s", icon.data(), file.name.data(), file.ext.data());
if(highlighted)
{
ImGui::PopStyleColor();
}
const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
if(ImGui::BeginPopupContextItem()) if(ImGui::BeginPopupContextItem())
{ {
@ -194,6 +253,27 @@ namespace SHADE
{ {
if (asset == nullptr) if (asset == nullptr)
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
if (!typeFilters[static_cast<uint64_t>(asset->type)])
{
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
}
bool highlighted = false;
if(!filter.empty())
{
ImGui::SetNextItemOpen(true);
if(SHStringUtilities::StringFindInsensitive(asset->name.data(), filter) == std::string::npos)
{
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
}
else
{
highlighted = true;
ImGui::PushStyleColor(ImGuiCol_Text, highlightedColor);
}
}
const bool isSelected = std::ranges::find(selectedAssets, asset->id) != selectedAssets.end(); const bool isSelected = std::ranges::find(selectedAssets, asset->id) != selectedAssets.end();
ImGuiTreeNodeFlags flags = (!asset->subAssets.empty()) ? ImGuiTreeNodeFlags_OpenOnArrow : ImGuiTreeNodeFlags_Leaf; ImGuiTreeNodeFlags flags = (!asset->subAssets.empty()) ? ImGuiTreeNodeFlags_OpenOnArrow : ImGuiTreeNodeFlags_Leaf;
if (isSelected) if (isSelected)
@ -215,7 +295,33 @@ namespace SHADE
default:; default:;
} }
if(assetToScrollTo != 0)
{
if(asset->id == assetToScrollTo)
{
ImGui::SetScrollHereY();
selectedAssets.clear();
selectedAssets.push_back(asset->id);
assetToScrollTo = 0;
}
else
{
for (auto const& subAsset : asset->subAssets)
{
if(subAsset->id == assetToScrollTo)
{
ImGui::SetNextItemOpen(true);
}
}
}
}
bool const isOpen = ImGui::TreeNodeEx(asset, flags, "%s %s%s", icon.data(), asset->name.data(), ext.data()); bool const isOpen = ImGui::TreeNodeEx(asset, flags, "%s %s%s", icon.data(), asset->name.data(), ext.data());
if(highlighted)
{
ImGui::PopStyleColor();
}
const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()); const ImRect nodeRect = ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
if (SHDragDrop::BeginSource()) if (SHDragDrop::BeginSource())
{ {
@ -339,4 +445,43 @@ namespace SHADE
// QueueRefresh(); // QueueRefresh();
//} //}
} }
void SHAssetBrowser::DrawAssetBrowserFilter()
{
if (ImGui::InputTextWithHint("##hierarchyPanelFilter", "Filter", &filter))
{
}
if (ImGui::Button("x"))
{
filter.clear();
}
if(ImGui::BeginMenu("Type"))
{
if (ImGui::Button("All"))
{
for (auto& [id, value] : typeFilters)
value = true;
}
ImGui::SameLine();
if (ImGui::Button("None"))
{
for (auto& [id, value] : typeFilters)
value = false;
}
for (auto& [id, value] : typeFilters)
{
if(ImGui::Checkbox(typeEnumAlign.value_to_name(id).data(), &value))
{
}
if(ImGui::IsItemClicked(ImGuiMouseButton_Right))
{
for (auto& [id2, value2] : typeFilters)
value2 = false;
value = true;
}
}
ImGui::EndMenu();
}
}
} }

View File

@ -4,18 +4,21 @@
#include "Assets/SHAsset.h" #include "Assets/SHAsset.h"
#include "Editor/EditorWindow/SHEditorWindow.h" #include "Editor/EditorWindow/SHEditorWindow.h"
#include "Filesystem/SHFolder.h" #include "Filesystem/SHFolder.h"
#include <rttr/enumeration.h>
namespace SHADE namespace SHADE
{ {
class SHAssetBrowser final : public SHEditorWindow class SHAssetBrowser final : public SHEditorWindow
{ {
public: public:
static constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f);
SHAssetBrowser(); SHAssetBrowser();
void Init(); void Init();
void Update(); void Update();
void QueueRefresh() noexcept; void QueueRefresh() noexcept;
void SetScrollTo(AssetID assetid);
private: private:
void DrawMenuBar(); void DrawMenuBar();
ImRect RecursivelyDrawTree(FolderPointer folder); ImRect RecursivelyDrawTree(FolderPointer folder);
@ -23,6 +26,7 @@ namespace SHADE
ImRect DrawFile(SHFile& file) noexcept; ImRect DrawFile(SHFile& file) noexcept;
ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept; ImRect DrawAsset(SHAsset const* const asset, FileExt const& ext = "") noexcept;
void DrawAssetBeingCreated() noexcept; void DrawAssetBeingCreated() noexcept;
void DrawAssetBrowserFilter();
void Refresh() noexcept; void Refresh() noexcept;
@ -30,9 +34,13 @@ namespace SHADE
std::vector<FolderPointer> selectedFolders; std::vector<FolderPointer> selectedFolders;
std::vector<AssetID> selectedAssets; std::vector<AssetID> selectedAssets;
static constexpr float tileWidth = 50.0f; static constexpr float tileWidth = 50.0f;
static constexpr std::string_view newAssetPopup = "Create New Asset";
std::string nameOfAssetBeingCreated, filter;
rttr::enumeration typeEnumAlign = rttr::type::get<AssetType>().get_enumeration();
std::unordered_map<uint64_t, bool> typeFilters;
AssetID assetToScrollTo = 0;
bool refreshQueued = false; bool refreshQueued = false;
bool isAssetBeingCreated = false; bool isAssetBeingCreated = false;
static constexpr std::string_view newAssetPopup = "Create New Asset";
std::string nameOfAssetBeingCreated;
}; };
} }

View File

@ -15,11 +15,11 @@
namespace SHADE namespace SHADE
{ {
class SHSceneNode; class SHSceneNode;
constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f);
class SHHierarchyPanel final : public SHEditorWindow class SHHierarchyPanel final : public SHEditorWindow
{ {
public: public:
static constexpr ImVec4 highlightedColor = ImVec4(0.f, 0.7f, 0.0f, 1.0f);
SHHierarchyPanel(); SHHierarchyPanel();
void Init() override; void Init() override;
void Update() override; void Update() override;

View File

@ -24,6 +24,8 @@
#include "SHInspectorCommands.h" #include "SHInspectorCommands.h"
#include "Physics/Collision/SHCollisionTagMatrix.h" #include "Physics/Collision/SHCollisionTagMatrix.h"
#include "Animation/SHAnimatorComponent.h" #include "Animation/SHAnimatorComponent.h"
#include "../SHEditorWindowManager.h"
#include "../AssetBrowser/SHAssetBrowser.h"
namespace SHADE namespace SHADE
{ {
template<typename T> template<typename T>
@ -502,6 +504,15 @@ namespace SHADE
SHResourceManager::FinaliseChanges(); SHResourceManager::FinaliseChanges();
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
if(Handle<SHMesh> const& mesh = component->GetMesh())
{
AssetID assetID = SHResourceManager::GetAssetID<SHMesh>(mesh).value_or(0);
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
}
}
const auto MAT_NAME = mat ? SHResourceManager::GetAssetName<SHMaterial>(mat->GetBaseMaterial()).value_or("") : ""; const auto MAT_NAME = mat ? SHResourceManager::GetAssetName<SHMaterial>(mat->GetBaseMaterial()).value_or("") : "";
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Material", MAT_NAME, SHEditorWidgets::DragDropReadOnlyField<AssetID>("Material", MAT_NAME,
[component]() [component]()
@ -521,6 +532,15 @@ namespace SHADE
auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>(); auto gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
component->SetMaterial(gfxSystem->AddOrGetBaseMaterialInstance(SHResourceManager::LoadOrGet<SHMaterial>(id))); component->SetMaterial(gfxSystem->AddOrGetBaseMaterialInstance(SHResourceManager::LoadOrGet<SHMaterial>(id)));
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
if(Handle<SHMaterialInstance> const& mat = component->GetMaterial())
{
AssetID assetID = SHResourceManager::GetAssetID<SHMaterial>(mat->GetBaseMaterial()).value_or(0);
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
}
}
} }
else else
{ {
@ -558,7 +578,14 @@ namespace SHADE
component->SetFont(SHResourceManager::LoadOrGet<SHFont>(id)); component->SetFont(SHResourceManager::LoadOrGet<SHFont>(id));
SHResourceManager::FinaliseChanges(); SHResourceManager::FinaliseChanges();
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
if (Handle<SHFont> const& font = component->GetFont())
{
AssetID assetID = SHResourceManager::GetAssetID<SHFont>(font).value_or(0);
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
}
}
SHEditorWidgets::InputText("Text", SHEditorWidgets::InputText("Text",
[component](void) [component](void)
{ {
@ -606,7 +633,14 @@ namespace SHADE
component->SetRig(SHResourceManager::LoadOrGet<SHRig>(id)); component->SetRig(SHResourceManager::LoadOrGet<SHRig>(id));
SHResourceManager::FinaliseChanges(); SHResourceManager::FinaliseChanges();
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
if (Handle<SHRig> const& rig = component->GetRig())
{
AssetID assetID = SHResourceManager::GetAssetID<SHRig>(rig).value_or(0);
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
}
}
Handle<SHAnimationClip> const& clip = component->GetCurrentClip(); Handle<SHAnimationClip> const& clip = component->GetCurrentClip();
const auto CLIP_NAME = clip ? SHResourceManager::GetAssetName<SHAnimationClip>(clip).value_or("") : ""; const auto CLIP_NAME = clip ? SHResourceManager::GetAssetName<SHAnimationClip>(clip).value_or("") : "";
SHEditorWidgets::DragDropReadOnlyField<AssetID>("Clip", CLIP_NAME, SHEditorWidgets::DragDropReadOnlyField<AssetID>("Clip", CLIP_NAME,
@ -624,6 +658,14 @@ namespace SHADE
} }
component->SetClip(SHResourceManager::LoadOrGet<SHAnimationClip>(id)); component->SetClip(SHResourceManager::LoadOrGet<SHAnimationClip>(id));
}, SHDragDrop::DRAG_RESOURCE); }, SHDragDrop::DRAG_RESOURCE);
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
{
if (Handle<SHAnimationClip> const& clip = component->GetCurrentClip())
{
AssetID assetID = SHResourceManager::GetAssetID<SHAnimationClip>(clip).value_or(0);
SHEditorWindowManager::GetEditorWindow<SHAssetBrowser>()->SetScrollTo(assetID);
}
}
} }
else else
{ {

View File

@ -1,8 +1,11 @@
#include "SHpch.h" #include "SHpch.h"
#include <memory>
#include <imgui.h>
#include "Serialization/SHSerializationHelper.hpp" #include "Serialization/SHSerializationHelper.hpp"
#include "SHMaterialInspector.h" #include "SHMaterialInspector.h"
#include "Editor/SHImGuiHelpers.hpp" #include "Editor/SHImGuiHelpers.hpp"
#include <imgui.h>
#include "Assets/SHAssetManager.h" #include "Assets/SHAssetManager.h"
#include "Editor/IconsMaterialDesign.h" #include "Editor/IconsMaterialDesign.h"
@ -89,12 +92,18 @@ namespace SHADE
if (vertShader && fragShader && gfxSystem) if (vertShader && fragShader && gfxSystem)
{ {
// - Retrieve pipeline from pipeline library // - Retrieve pipeline from pipeline library
auto renderPass = gfxSystem->GetPrimaryRenderpass(); auto subPass = gfxSystem->GetUsableSubpass(currentMatSpec->subpassName);
auto subPass = renderPass->GetSubpass(currentMatSpec->subpassName); if (subPass)
auto pipeline = renderPass->GetOrCreatePipeline({ vertShader, fragShader }, subPass); {
// - Set Pipeline // Set Pipeline if valid
auto pipeline = subPass->GetParentNode()->GetOrCreatePipeline({vertShader, fragShader}, subPass);
matHandle->SetPipeline(pipeline); matHandle->SetPipeline(pipeline);
} }
else
{
SHLOG_ERROR("[SHMaterialInspector] Failed to find material subpass of type \"{}\"", currentMatSpec->subpassName);
}
}
} }
// Save Properties // Save Properties
@ -176,7 +185,7 @@ namespace SHADE
const std::string VERT_SHADER_NAME = VERT_SHADER_INFO ? VERT_SHADER_INFO->name : "Unknown Shader"; const std::string VERT_SHADER_NAME = VERT_SHADER_INFO ? VERT_SHADER_INFO->name : "Unknown Shader";
isDirty |= SHEditorWidgets::DragDropReadOnlyField<AssetID> isDirty |= SHEditorWidgets::DragDropReadOnlyField<AssetID>
( (
"Fragment Shader", VERT_SHADER_NAME.data(), "Vertex Shader", VERT_SHADER_NAME.data(),
[this]() { return currentMatSpec->vertexShader; }, [this]() { return currentMatSpec->vertexShader; },
[this](const AssetID& id) { currentMatSpec->vertexShader = id; }, [this](const AssetID& id) { currentMatSpec->vertexShader = id; },
SHDragDrop::DRAG_RESOURCE SHDragDrop::DRAG_RESOURCE
@ -191,6 +200,37 @@ namespace SHADE
SHDragDrop::DRAG_RESOURCE SHDragDrop::DRAG_RESOURCE
); );
// Subpass
const auto& SP_NAMES = SHGraphicsConstants::RenderGraphEntityNames::USABLE_SUBPASSES;
ImGui::Text("Subpass");
ImGui::SameLine();
if (ImGui::BeginCombo("##", currentMatSpec->subpassName.data(), ImGuiComboFlags_None))
{
for (const auto& NAME : SP_NAMES)
{
const bool IS_SELECTED = currentMatSpec->subpassName == NAME;
if (ImGui::Selectable(NAME.data(), IS_SELECTED))
{
isDirty = true;
SHCommandManager::PerformCommand
(
std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<std::string>>
(
currentMatSpec->subpassName,
std::string(NAME),
[&](const std::string& newName){ currentMatSpec->subpassName = newName; }
)),
false
);
}
if (IS_SELECTED)
{
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
// Load the shader to access it's data // Load the shader to access it's data
auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec->fragShader); auto fragShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec->fragShader);
if (!fragShader) if (!fragShader)

View File

@ -97,7 +97,9 @@ namespace SHADE
} }
} }
#ifdef SHEDITOR
editorConfig = &SHConfigurationManager::LoadEditorConfig(); editorConfig = &SHConfigurationManager::LoadEditorConfig();
#endif
//Add editor windows //Add editor windows
SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>(); SHEditorWindowManager::CreateEditorWindow<SHEditorMenuBar>();
@ -131,8 +133,9 @@ namespace SHADE
InitBackend(); InitBackend();
#ifdef SHEDITOR
SetStyle(static_cast<Style>(editorConfig->style)); SetStyle(static_cast<Style>(editorConfig->style));
#endif // SHEDITOR
for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values)
{ {
@ -340,13 +343,18 @@ namespace SHADE
ImGui_ImplSDL2_Shutdown(); ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext(); ImGui::DestroyContext();
#ifdef SHEDITOR
editorConfig->startMaximized = shWindow->GetWindowData().isMaximised; editorConfig->startMaximized = shWindow->GetWindowData().isMaximised;
SHConfigurationManager::SaveEditorConfig(); SHConfigurationManager::SaveEditorConfig();
#endif // SHEDITOR
} }
void SHEditor::SetStyle(Style style) void SHEditor::SetStyle(Style style)
{ {
#ifdef SHEDITOR
editorConfig->style = static_cast<uint32_t>(style); editorConfig->style = static_cast<uint32_t>(style);
#endif // SHEDITOR
switch (style) switch (style)
{ {
default: default:
@ -550,7 +558,10 @@ namespace SHADE
SHSceneManager::SetCurrentSceneName(newSceneName); SHSceneManager::SetCurrentSceneName(newSceneName);
SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName)); SHSceneManager::SetCurrentSceneAssetID(SHAssetManager::CreateNewAsset(AssetType::SCENE, newSceneName));
#ifdef SHEDITOR
editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID(); editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID();
#endif // SHEDITOR
} }
//Get data, if data is null, asset doesn't exist, prompt for a name and create a new asset with the name //Get data, if data is null, asset doesn't exist, prompt for a name and create a new asset with the name
@ -559,7 +570,10 @@ namespace SHADE
{ {
if(shWindow->IsUnsavedChanges()) if(shWindow->IsUnsavedChanges())
shWindow->ToggleUnsavedChanges(); shWindow->ToggleUnsavedChanges();
#ifdef SHEDITOR
editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID(); editorConfig->workingSceneID = SHSceneManager::GetCurrentSceneAssetID();
#endif // SHEDITOR
return true; return true;
} }
return false; return false;
@ -624,7 +638,11 @@ namespace SHADE
editorState = SHEditor::State::STOP; editorState = SHEditor::State::STOP;
SHCommandManager::SwapStacks(); SHCommandManager::SwapStacks();
SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT); SHEventManager::BroadcastEvent<SHEditorStateChangeEvent>(STATE_CHANGE_EVENT, SH_EDITOR_ON_STOP_EVENT);
#ifdef SHEDITOR
LoadScene(editorConfig->workingSceneID); LoadScene(editorConfig->workingSceneID);
#endif // SHEDITOR
} }
void SHEditor::ProcessShortcuts() void SHEditor::ProcessShortcuts()
@ -679,7 +697,9 @@ namespace SHADE
if(width > 0 && height > 0) if(width > 0 && height > 0)
{ {
auto [width, height] = shWindow->GetWindowSize(); auto [width, height] = shWindow->GetWindowSize();
#ifdef SHEditor
editorConfig->windowSize = { static_cast<float>(width), static_cast<float>(height) }; editorConfig->windowSize = { static_cast<float>(width), static_cast<float>(height) };
#endif // SHEditor
} }
}); });
} }

View File

@ -127,8 +127,9 @@ namespace SHADE
std::vector<EntityID> selectedEntities; std::vector<EntityID> selectedEntities;
State editorState = State::STOP; State editorState = State::STOP;
#ifdef SHEDITOR
SHEditorConfig* editorConfig; SHEditorConfig* editorConfig;
#endif // SHEDITOR
private: private:
/** /**

View File

@ -424,7 +424,7 @@ namespace SHADE
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::PushID(label.data()); ImGui::PushID(label.data());
TextLabel(label); TextLabel(label);
bool changed = ImGui::InputText("##inputText", &text, ImGuiInputTextFlags_ReadOnly, nullptr, nullptr); bool changed = ImGui::InputText("##inputText", &text, ImGuiInputTextFlags_ReadOnly | ImGuiInputTextFlags_AutoSelectAll, nullptr, nullptr);
if(SHDragDrop::BeginTarget()) if(SHDragDrop::BeginTarget())
{ {
if(T* payload = SHDragDrop::AcceptPayload<T>(dragDropTag)) if(T* payload = SHDragDrop::AcceptPayload<T>(dragDropTag))

View File

@ -13,6 +13,7 @@ of DigiPen Institute of Technology is prohibited.
// STL Includes // STL Includes
#include <cstdint> #include <cstdint>
#include <string>
namespace SHADE namespace SHADE
{ {
@ -114,7 +115,14 @@ namespace SHADE
static constexpr std::string_view DEFERRED_COMPOSITE_COMPUTE = "Deferred Composite"; static constexpr std::string_view DEFERRED_COMPOSITE_COMPUTE = "Deferred Composite";
static constexpr std::string_view GBUFFER_WRITE_SUBPASS = "G-Buffer Write";
static constexpr std::string_view UI_SUBPASS = "UI";
static constexpr std::array USABLE_SUBPASSES =
{
GBUFFER_WRITE_SUBPASS,
UI_SUBPASS
};
}; };
struct DescriptorSetBindings struct DescriptorSetBindings

View File

@ -133,6 +133,9 @@ namespace SHADE
//SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/PureCopy_CS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_VS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false); //SHAssetManager::CompileAsset("../../Assets/Shaders/TestCube_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_VS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/UI_FS.glsl", false);
//SHAssetManager::CompileAsset("../../Assets/Shaders/Text_VS.glsl", false);
// Load Built In Shaders // Load Built In Shaders
static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT); static constexpr AssetID VS_DEFAULT = 39210065; defaultVertShader = SHResourceManager::LoadOrGet<SHVkShaderModule>(VS_DEFAULT);
@ -232,7 +235,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* G-BUFFER SUBPASS INIT */ /* G-BUFFER SUBPASS INIT */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
auto gBufferSubpass = gBufferNode->AddSubpass("G-Buffer Write", worldViewport, worldRenderer); auto gBufferSubpass = gBufferNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data(), worldViewport, worldRenderer);
gBufferSubpass->AddColorOutput("Position"); gBufferSubpass->AddColorOutput("Position");
gBufferSubpass->AddColorOutput("Entity ID"); gBufferSubpass->AddColorOutput("Entity ID");
gBufferSubpass->AddColorOutput("Light Layer Indices"); gBufferSubpass->AddColorOutput("Light Layer Indices");
@ -241,6 +244,7 @@ namespace SHADE
gBufferSubpass->AddColorOutput("Position World Space"); gBufferSubpass->AddColorOutput("Position World Space");
gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL); gBufferSubpass->AddDepthOutput("Depth Buffer", SH_RENDER_GRAPH_RESOURCE_FLAGS::DEPTH_STENCIL);
usableSubpassesMapping.emplace (std::string (SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS.data()), gBufferSubpass);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* SSAO PASS AND DATA INIT */ /* SSAO PASS AND DATA INIT */
@ -319,7 +323,7 @@ namespace SHADE
/* SCREEN SPACE PASS */ /* SCREEN SPACE PASS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
auto screenSpaceNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data(), {"Scene", "Entity ID"}, {SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW.data()}); auto screenSpaceNode = renderGraph->AddNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data(), {"Scene", "Entity ID"}, {SHGraphicsConstants::RenderGraphEntityNames::DEFERRED_COMPOSITE_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data(), SHGraphicsConstants::RenderGraphEntityNames::DEBUG_DRAW.data()});
auto uiSubpass = screenSpaceNode->AddSubpass("UI", worldViewport, screenRenderer); auto uiSubpass = screenSpaceNode->AddSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS.data(), worldViewport, screenRenderer);
uiSubpass->AddColorOutput("Scene"); uiSubpass->AddColorOutput("Scene");
uiSubpass->AddColorOutput("Entity ID"); uiSubpass->AddColorOutput("Entity ID");
uiSubpass->AddExteriorDrawCalls([=](Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex) uiSubpass->AddExteriorDrawCalls([=](Handle<SHVkCommandBuffer> cmdBuffer, Handle<SHRenderer> renderer, uint32_t frameIndex)
@ -327,6 +331,8 @@ namespace SHADE
textRenderingSubSystem->Render(cmdBuffer, renderer, frameIndex); textRenderingSubSystem->Render(cmdBuffer, renderer, frameIndex);
}); });
usableSubpassesMapping.emplace(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS.data(), uiSubpass);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* RENDER TO SWAPCHAIN IMAGE FOR PRESENT PASS */ /* RENDER TO SWAPCHAIN IMAGE FOR PRESENT PASS */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -421,7 +427,7 @@ namespace SHADE
// initialize the text renderer // initialize the text renderer
auto uiNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data()); auto uiNode = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::SCREEN_SPACE_PASS.data());
textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass("UI"), descPool, textVS, textFS); textRenderingSubSystem->Init(device, uiNode->GetRenderpass(), uiNode->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::UI_SUBPASS), descPool, textVS, textFS);
SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem); SHGlobalDescriptorSets::SetLightingSubSystem(lightingSubSystem);
@ -448,7 +454,7 @@ namespace SHADE
defaultMaterial = AddMaterial defaultMaterial = AddMaterial
( (
defaultVertShader, defaultFragShader, defaultVertShader, defaultFragShader,
renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass("G-Buffer Write") renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS)
); );
defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex); defaultMaterial->SetProperty("data.textureIndex", defaultTexture->TextureArrayIndex);
defaultAnimMaterial = AddMaterial defaultAnimMaterial = AddMaterial
@ -573,7 +579,7 @@ namespace SHADE
else else
renderer->UpdateData(frameIndex); renderer->UpdateData(frameIndex);
#else #else
renderers[renIndex]->UpdateDataAndBind(frameIndex); renderer->UpdateData(frameIndex);
#endif #endif
} }
@ -589,16 +595,8 @@ namespace SHADE
renderGraph->Begin(frameIndex); renderGraph->Begin(frameIndex);
auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex); auto cmdBuffer = renderGraph->GetCommandBuffer(frameIndex);
// Bind all the buffers required for meshes
for (auto& [buffer, bindingPoint] : MESH_DATA)
{
if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer)
cmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0);
else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer)
cmdBuffer->BindIndexBuffer(buffer, 0);
}
renderGraph->Execute(frameIndex, descPool); renderGraph->Execute(frameIndex, descPool, MESH_DATA);
renderGraph->End(frameIndex); renderGraph->End(frameIndex);
graphicsQueue->SubmitCommandBuffer graphicsQueue->SubmitCommandBuffer
@ -774,7 +772,7 @@ namespace SHADE
auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHLightEnableShadowEvent>*>(eventPtr.get())->data; auto const& EVENT_DATA = reinterpret_cast<const SHEventSpec<SHLightEnableShadowEvent>*>(eventPtr.get())->data;
auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity); auto* lightComp = SHComponentManager::GetComponent<SHLightComponent>(EVENT_DATA->lightEntity);
std::string resourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity); std::string resourceName = "ShadowMap " + std::to_string(EVENT_DATA->lightEntity);
Handle<SHSubpass> companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass("G-Buffer Write"); Handle<SHSubpass> companionSubpass = renderGraph->GetNode(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_PASS.data())->GetSubpass(SHGraphicsConstants::RenderGraphEntityNames::GBUFFER_WRITE_SUBPASS);
if (EVENT_DATA->generateRenderer) if (EVENT_DATA->generateRenderer)
{ {
@ -1196,6 +1194,16 @@ namespace SHADE
return fontLibrary; return fontLibrary;
} }
Handle <SHSubpass> SHGraphicsSystem::GetUsableSubpass(std::string const& subpassName) const noexcept
{
if (usableSubpassesMapping.contains(subpassName))
{
return usableSubpassesMapping.at (subpassName);
}
else
return {};
}
Handle<SHVkPipeline> SHGraphicsSystem::createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass, bool filled, bool triMesh, bool instanced) Handle<SHVkPipeline> SHGraphicsSystem::createDebugDrawPipeline(Handle<SHVkRenderpass> renderPass, Handle<SHSubpass> subpass, bool filled, bool triMesh, bool instanced)
{ {
auto pipelineLayout = resourceManager.Create<SHVkPipelineLayout> auto pipelineLayout = resourceManager.Create<SHVkPipelineLayout>

View File

@ -399,6 +399,7 @@ namespace SHADE
uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); } uint32_t GetCurrentFrameIndex(void) const noexcept { return renderContext.GetCurrentFrame(); }
SHFontLibrary const& GetFontLibrary (void) const noexcept; SHFontLibrary const& GetFontLibrary (void) const noexcept;
const SHMeshLibrary& GetMeshLibrary() const noexcept { return meshLibrary; }; const SHMeshLibrary& GetMeshLibrary() const noexcept { return meshLibrary; };
Handle <SHSubpass> GetUsableSubpass(std::string const& subpassName) const noexcept;
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
/* Getters */ /* Getters */
@ -509,6 +510,8 @@ namespace SHADE
uint32_t resizeHeight = 1; uint32_t resizeHeight = 1;
bool restoredFromMinimize = false; bool restoredFromMinimize = false;
std::unordered_map<std::string, Handle<SHSubpass>> usableSubpassesMapping{};
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Helper Functions */ /* Helper Functions */
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/

View File

@ -565,7 +565,7 @@ namespace SHADE
// TODO: The graph scope buffers were meant to bind vertex buffers and index buffers for meshes. Find a // TODO: The graph scope buffers were meant to bind vertex buffers and index buffers for meshes. Find a
// better way to manage these // better way to manage these
void SHRenderGraph::Execute(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool) noexcept void SHRenderGraph::Execute(uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool, const std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> MESH_DATA) noexcept
{ {
auto cmdBuffer = commandBuffers[frameIndex]; auto cmdBuffer = commandBuffers[frameIndex];
cmdBuffer->BeginLabeledSegment(name); cmdBuffer->BeginLabeledSegment(name);
@ -578,6 +578,7 @@ namespace SHADE
auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING); auto const& descMappings = SHGraphicsPredefinedData::GetMappings(SHGraphicsPredefinedData::SystemType::BATCHING);
for (auto& node : nodes) for (auto& node : nodes)
{ {
if (node->renderpass) if (node->renderpass)
@ -585,6 +586,15 @@ namespace SHADE
// bind static global data // bind static global data
SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA)); SHGlobalDescriptorSets::BindStaticGlobalData(cmdBuffer, SH_PIPELINE_TYPE::GRAPHICS, descMappings.at(SHPredefinedDescriptorTypes::STATIC_DATA));
// Bind all the buffers required for meshes
for (auto& [buffer, bindingPoint] : MESH_DATA)
{
if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eVertexBuffer)
cmdBuffer->BindVertexBuffer(bindingPoint, buffer, 0);
else if (buffer->GetUsageBits() & vk::BufferUsageFlagBits::eIndexBuffer)
cmdBuffer->BindIndexBuffer(buffer, 0);
}
node->Execute(cmdBuffer, descPool, frameIndex); node->Execute(cmdBuffer, descPool, frameIndex);
} }
} }

View File

@ -143,7 +143,7 @@ namespace SHADE
void Generate (void) noexcept; void Generate (void) noexcept;
void CheckForNodeComputes (void) noexcept; void CheckForNodeComputes (void) noexcept;
void Execute (uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool) noexcept; void Execute (uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool, const std::initializer_list<std::pair<Handle<SHVkBuffer>, uint32_t>> MESH_DATA) noexcept;
void Begin (uint32_t frameIndex) noexcept; void Begin (uint32_t frameIndex) noexcept;
void End (uint32_t frameIndex) noexcept; void End (uint32_t frameIndex) noexcept;
void FinaliseBatch (uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool); void FinaliseBatch (uint32_t frameIndex, Handle<SHVkDescriptorPool> descPool);

View File

@ -474,7 +474,7 @@ namespace SHADE
*/ */
/***************************************************************************/ /***************************************************************************/
Handle<SHRenderGraphNode> const& SHSubpass::GetParentNode(void) const noexcept Handle<SHRenderGraphNode> SHSubpass::GetParentNode(void) const noexcept
{ {
return parentNode; return parentNode;
} }

View File

@ -159,7 +159,7 @@ namespace SHADE
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
void SetCompanionSubpass (Handle<SHSubpass> companion, Handle<SHVkPipeline> pipeline) noexcept; void SetCompanionSubpass (Handle<SHSubpass> companion, Handle<SHVkPipeline> pipeline) noexcept;
Handle<SHRenderGraphNode> const& GetParentNode(void) const noexcept; Handle<SHRenderGraphNode> GetParentNode(void) const noexcept;
SHSubPassIndex GetIndex() const noexcept; SHSubPassIndex GetIndex() const noexcept;
Handle<SHSuperBatch> GetSuperBatch(void) const noexcept; Handle<SHSuperBatch> GetSuperBatch(void) const noexcept;
std::vector<vk::AttachmentReference> const& GetColorAttachmentReferences (void) const noexcept; std::vector<vk::AttachmentReference> const& GetColorAttachmentReferences (void) const noexcept;

View File

@ -280,14 +280,8 @@ namespace SHADE
return {}; return {};
} }
// Grab subpass from worldRenderer // Grab subpass
auto renderPass = gfxSystem->GetPrimaryRenderpass(); auto subPass = gfxSystem->GetUsableSubpass(assetData.subpassName);
if (!renderPass)
{
SHLOG_ERROR("[SHResourceManager] Failed to load material as RenderPass could not be found.");
return {};
}
auto subPass = renderPass->GetSubpass(assetData.subpassName);
if (!subPass) if (!subPass)
{ {
SHLOG_ERROR("[SHResourceManager] Failed to load material as SubPass could not be found."); SHLOG_ERROR("[SHResourceManager] Failed to load material as SubPass could not be found.");

View File

@ -182,7 +182,7 @@ namespace SHADE
mousePos.x = x; mousePos.x = x;
mousePos.y = y; mousePos.y = y;
auto ws = SHSystemManager::GetSystem<SHGraphicsSystem>()->GetWindow()->GetWindowSize(); auto ws = SHSystemManager::GetSystem<SHGraphicsSystem>()->GetWindow()->GetWindowSize();
windowSize = { ws.first,ws.second }; windowSize = { static_cast<float>(ws.first), static_cast<float>(ws.second) };
mousePos /= windowSize; mousePos /= windowSize;
#endif #endif
@ -300,7 +300,7 @@ namespace SHADE
mousePos.x = x; mousePos.x = x;
mousePos.y = y; mousePos.y = y;
auto ws = SHSystemManager::GetSystem<SHGraphicsSystem>()->GetWindow()->GetWindowSize(); auto ws = SHSystemManager::GetSystem<SHGraphicsSystem>()->GetWindow()->GetWindowSize();
windowSize = { ws.first,ws.second }; windowSize = { static_cast<float>(ws.first), static_cast<float>(ws.second) };
mousePos /= windowSize; mousePos /= windowSize;
#endif #endif