|
|
|
@ -3,22 +3,22 @@
|
|
|
|
|
#include "Editor/SHImGuiHelpers.hpp"
|
|
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
|
|
//#include "Assets/SHAssetManager.h"
|
|
|
|
|
//#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
|
|
|
|
|
//#include "Editor/SHEditorWidgets.hpp"
|
|
|
|
|
//#include "Resource/SHResourceManager.h"
|
|
|
|
|
#include "Assets/SHAssetManager.h"
|
|
|
|
|
#include "Graphics/MiddleEnd/Materials/SHMaterialSpec.h"
|
|
|
|
|
#include "Editor/SHEditorWidgets.hpp"
|
|
|
|
|
#include "Resource/SHResourceManager.h"
|
|
|
|
|
|
|
|
|
|
namespace SHADE
|
|
|
|
|
{
|
|
|
|
|
SHMaterialInspector::SHMaterialInspector()
|
|
|
|
|
:SHEditorWindow("Material Inspector", ImGuiWindowFlags_MenuBar)//,isNewMaterial(false), currentViewedMaterial(0)
|
|
|
|
|
:SHEditorWindow("Material Inspector", ImGuiWindowFlags_MenuBar), isNewMaterial(false), currentViewedMaterial(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::OpenMaterial(AssetID const& assetId) noexcept
|
|
|
|
|
{
|
|
|
|
|
//Get mat data
|
|
|
|
|
//isNewMaterial = false;
|
|
|
|
|
isNewMaterial = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::Init()
|
|
|
|
@ -30,30 +30,20 @@ namespace SHADE
|
|
|
|
|
{
|
|
|
|
|
SHEditorWindow::Update();
|
|
|
|
|
|
|
|
|
|
//if(Begin())
|
|
|
|
|
//{
|
|
|
|
|
// DrawMenuBar();
|
|
|
|
|
if(Begin())
|
|
|
|
|
{
|
|
|
|
|
DrawMenuBar();
|
|
|
|
|
|
|
|
|
|
// if(SHEditorWidgets::DragDropReadOnlyField<AssetID>("Vertex Shader", std::to_string(currentMatSpec.vertexShader), [&](){return currentMatSpec.vertexShader;}, [&](AssetID const& id){currentMatSpec.vertexShader = id;}, SHDragDrop::DRAG_RESOURCE))
|
|
|
|
|
// {
|
|
|
|
|
// vertShaderHandle = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec.vertexShader);
|
|
|
|
|
// }
|
|
|
|
|
// if(SHEditorWidgets::DragDropReadOnlyField<AssetID>("Fragment Shader", std::to_string(currentMatSpec.fragShader), [&](){return currentMatSpec.fragShader;}, [&](AssetID const& id){currentMatSpec.fragShader = id;}, SHDragDrop::DRAG_RESOURCE))
|
|
|
|
|
// {
|
|
|
|
|
// fragShaderHandle = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec.fragShader);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// auto vertInterface = vertShaderHandle->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA);
|
|
|
|
|
|
|
|
|
|
// int const varCount = static_cast<int>(vertInterface->GetVariableCount());
|
|
|
|
|
//
|
|
|
|
|
// for(int i = 0; i < varCount; ++i)
|
|
|
|
|
// {
|
|
|
|
|
// auto variable = vertInterface->GetVariable(i);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
//ImGui::End();
|
|
|
|
|
if(SHEditorWidgets::DragDropReadOnlyField<AssetID>("Vertex Shader", std::to_string(currentMatSpec.vertexShader), [&](){return currentMatSpec.vertexShader;}, [&](AssetID const& id){currentMatSpec.vertexShader = id;}, SHDragDrop::DRAG_RESOURCE))
|
|
|
|
|
{
|
|
|
|
|
vertShaderHandle = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec.vertexShader);
|
|
|
|
|
}
|
|
|
|
|
if(SHEditorWidgets::DragDropReadOnlyField<AssetID>("Fragment Shader", std::to_string(currentMatSpec.fragShader), [&](){return currentMatSpec.fragShader;}, [&](AssetID const& id){currentMatSpec.fragShader = id;}, SHDragDrop::DRAG_RESOURCE))
|
|
|
|
|
{
|
|
|
|
|
fragShaderHandle = SHResourceManager::LoadOrGet<SHVkShaderModule>(currentMatSpec.fragShader);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ImGui::End();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::Exit()
|
|
|
|
@ -63,12 +53,12 @@ namespace SHADE
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::CreateNewMaterial()
|
|
|
|
|
{
|
|
|
|
|
//isNewMaterial = true;
|
|
|
|
|
////prompt for a name
|
|
|
|
|
//currentViewedMaterial = SHAssetManager::CreateNewAsset(AssetType::MATERIAL, "NewMaterial");
|
|
|
|
|
//currentMatSpec = {};
|
|
|
|
|
//vertShaderHandle = {};
|
|
|
|
|
//fragShaderHandle = {};
|
|
|
|
|
isNewMaterial = true;
|
|
|
|
|
//prompt for a name
|
|
|
|
|
currentViewedMaterial = SHAssetManager::CreateNewAsset(AssetType::MATERIAL, "NewMaterial");
|
|
|
|
|
currentMatSpec = {};
|
|
|
|
|
vertShaderHandle = {};
|
|
|
|
|
fragShaderHandle = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::DrawMenuBar()
|
|
|
|
@ -78,4 +68,50 @@ namespace SHADE
|
|
|
|
|
ImGui::EndMenuBar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SHMaterialInspector::DrawShaderProperties(Handle<SHVkShaderModule> shaderModule)
|
|
|
|
|
{
|
|
|
|
|
auto interface = shaderModule->GetReflectedData().GetDescriptorBindingInfo().GetShaderBlockInterface(SHGraphicsConstants::DescriptorSetIndex::PER_INSTANCE, SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA);
|
|
|
|
|
|
|
|
|
|
int const varCount = static_cast<int>(interface->GetVariableCount());
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < varCount; ++i)
|
|
|
|
|
{
|
|
|
|
|
auto variable = interface->GetVariable(i);
|
|
|
|
|
const std::string& VAR_NAME = interface->GetVariableName(i);
|
|
|
|
|
switch (variable->type)
|
|
|
|
|
{
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::FLOAT:
|
|
|
|
|
SHEditorWidgets::DragFloat(VAR_NAME, [&]()
|
|
|
|
|
{
|
|
|
|
|
if(currentMatSpec.properties[VAR_NAME].IsDefined())
|
|
|
|
|
return currentMatSpec.properties[VAR_NAME].as<float>();
|
|
|
|
|
else
|
|
|
|
|
return 0.0f;
|
|
|
|
|
},
|
|
|
|
|
[&](float const& value)
|
|
|
|
|
{
|
|
|
|
|
currentMatSpec.properties[VAR_NAME] = value;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::INT:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::VECTOR2:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::VECTOR3:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::VECTOR4:
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case SHShaderBlockInterface::Variable::Type::OTHER:
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|