From 4ab59bf7e8bab9e777f1d40d030083d90569ad7f Mon Sep 17 00:00:00 2001 From: antopilo Date: Thu, 21 Nov 2024 21:06:14 -0500 Subject: [PATCH] Moved environment to a resource and a component --- Editor/src/Windows/EditorInterface.cpp | 1028 ---------------- Editor/src/Windows/EditorSelectionPanel.cpp | 1046 +++++++++++++++++ Editor/src/Windows/FileSystemUI.cpp | 30 + Nuake/src/Core/RegisterCoreTypes.cpp | 3 + Nuake/src/FileSystem/File.cpp | 10 + Nuake/src/FileSystem/FileTypes.h | 3 +- .../src/Rendering/Textures/TextureManager.cpp | 1 + Nuake/src/Resource/ResourceLoader.cpp | 47 + Nuake/src/Resource/ResourceLoader.h | 2 + Nuake/src/Resource/StaticResources.cpp | 89 ++ Nuake/src/Resource/StaticResources.h | 3 + Nuake/src/Scene/Components.h | 1 + .../Scene/Components/EnvironmentComponent.cpp | 19 + .../Scene/Components/EnvironmentComponent.h | 30 + Nuake/src/Scene/Entities/Entity.cpp | 3 + Nuake/src/Scene/Lighting/Environment.cpp | 15 +- Nuake/src/Scene/Lighting/Environment.h | 4 +- Nuake/src/Scene/Scene.cpp | 42 +- Nuake/src/Scene/Scene.h | 5 +- Nuake/src/UI/ImUI.h | 13 + Resources/Images/env_file_icon.png | Bin 0 -> 985 bytes 21 files changed, 1343 insertions(+), 1051 deletions(-) create mode 100644 Nuake/src/Scene/Components/EnvironmentComponent.cpp create mode 100644 Nuake/src/Scene/Components/EnvironmentComponent.h create mode 100644 Resources/Images/env_file_icon.png diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index a03d7321..a36b55fc 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -1205,18 +1205,7 @@ namespace Nuake { ImGui::PopFont(); } -#define BEGIN_COLLAPSE_HEADER(names) \ - UIFont* names##_boldFont = new UIFont(Fonts::Bold); \ - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f)); \ - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 8.f)); \ - bool names##_Opened = ImGui::CollapsingHeader((std::string(" ") + #names).c_str()); \ - ImGui::PopStyleVar(); \ - delete names##_boldFont; \ - if (names##_Opened) { \ -#define END_COLLAPSE_HEADER() \ -} \ - ImGui::PopStyleVar(); \ void EditorInterface::DrawSceneTree() { @@ -1224,1023 +1213,6 @@ namespace Nuake { if (!scene) return; - const Ref env = Engine::GetCurrentScene()->GetEnvironment(); - - if (ImGui::Begin((ICON_FA_MOUNTAIN + std::string(" Environment")).c_str())) - { - BEGIN_COLLAPSE_HEADER(SKY); - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Sky Type"); - ImGui::TableNextColumn(); - - // Here we create a dropdown for every sky type. - const char* SkyTypes[] = { "Procedural Sky", "Color" }; - static int currentSkyType = (int)env->CurrentSkyType; - ImGui::Combo("##SkyType", ¤tSkyType, SkyTypes, IM_ARRAYSIZE(SkyTypes)); - env->CurrentSkyType = (SkyType)currentSkyType; - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); - if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Gamma"); - ImGui::TableNextColumn(); - - // Here we create a dropdown for every sky type. - ImGui::DragFloat("##gamma", &env->Gamma, 0.001f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); - if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Exposure"); - ImGui::TableNextColumn(); - - // Here we create a dropdown for every sky type. - ImGui::DragFloat("##exposure", &env->Exposure, 0.001f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); - if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; - ImGui::PopStyleColor(); - } - - if (env->CurrentSkyType == SkyType::ProceduralSky) - { - ImGui::TableNextColumn(); - - { // Sun Intensity - ImGui::Text("Sun Intensity"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##Sun Intensity", &env->ProceduralSkybox->SunIntensity, 0.1f, 0.0f, 1000.0f); - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSunIntensity = ICON_FA_UNDO + std::string("##ResetSunIntensity"); - if (ImGui::Button(resetSunIntensity.c_str())) env->ProceduralSkybox->SunIntensity = 100.0f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // Sun Direction - ImGui::Text("Sun Direction"); - ImGui::TableNextColumn(); - - Vector3 sunDirection = env->ProceduralSkybox->GetSunDirection(); - ImGuiHelper::DrawVec3("##Sun Direction", &sunDirection); - env->ProceduralSkybox->SunDirection = glm::mix(env->ProceduralSkybox->GetSunDirection(), glm::normalize(sunDirection), 0.1f); - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSunDirection = ICON_FA_UNDO + std::string("##resetSunDirection"); - if (ImGui::Button(resetSunDirection.c_str())) env->ProceduralSkybox->SunDirection = Vector3(0.20000f, 0.95917f, 0.20000f); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // Surface Radius - ImGui::Text("Surface Radius"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##surfaceRadius", &env->ProceduralSkybox->SurfaceRadius, 100.f, 0.0f); - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSurfaceRadius = ICON_FA_UNDO + std::string("##resetSurfaceRadius"); - if (ImGui::Button(resetSurfaceRadius.c_str())) env->ProceduralSkybox->SurfaceRadius = 6360e3f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // Atmosphere Radius - ImGui::Text("Atmosphere Radius"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##AtmosphereRadius", &env->ProceduralSkybox->AtmosphereRadius, 100.f, 0.0f); - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetAtmosphereRadius = ICON_FA_UNDO + std::string("##resetAtmosphereRadius"); - if (ImGui::Button(resetAtmosphereRadius.c_str())) env->ProceduralSkybox->AtmosphereRadius = 6380e3f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // Center point - ImGui::Text("Center Point"); - ImGui::TableNextColumn(); - - ImGuiHelper::DrawVec3("##Center Point", &env->ProceduralSkybox->CenterPoint, 0.0f, 100.0f, 100.0f); - ImGui::TableNextColumn(); - if (env->ProceduralSkybox->CenterPoint.y < -env->ProceduralSkybox->AtmosphereRadius) - env->ProceduralSkybox->CenterPoint.y = -env->ProceduralSkybox->AtmosphereRadius + 1.f; - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetCenterPoint = ICON_FA_UNDO + std::string("##resetAtmosphereRadius"); - if (ImGui::Button(resetCenterPoint.c_str())) env->ProceduralSkybox->CenterPoint = Vector3(0, -env->ProceduralSkybox->AtmosphereRadius, 0); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // Mie Scattering - ImGui::Text("Mie Scattering"); - ImGui::TableNextColumn(); - - Vector3 mieScattering = env->ProceduralSkybox->MieScattering * 10000.0f; - ImGuiHelper::DrawVec3("##Mie Scattering", &mieScattering, 0.0f, 100.0f, 0.01f); - if (mieScattering.x < 0) mieScattering.x = 0; - if (mieScattering.y < 0) mieScattering.y = 0; - if (mieScattering.z < 0) mieScattering.z = 0; - env->ProceduralSkybox->MieScattering = mieScattering / 10000.0f; - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetMieScattering = ICON_FA_UNDO + std::string("##resetMieScattering"); - if (ImGui::Button(resetMieScattering.c_str())) env->ProceduralSkybox->MieScattering = Vector3(2e-5f); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { // RayleighScattering - ImGui::Text("Rayleigh Scattering"); - ImGui::TableNextColumn(); - - Vector3 rayleighScattering = env->ProceduralSkybox->RayleighScattering * 10000.0f; - ImGuiHelper::DrawVec3("##Ray Scattering", &rayleighScattering, 0.0f, 100.0f, 0.01f); - if (rayleighScattering.r < 0) rayleighScattering.r = 0; - if (rayleighScattering.g < 0) rayleighScattering.g = 0; - if (rayleighScattering.b < 0) rayleighScattering.b = 0; - env->ProceduralSkybox->RayleighScattering = rayleighScattering / 10000.0f; - ImGui::TableNextColumn(); - - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetRayScattering = ICON_FA_UNDO + std::string("##resetRayScattering"); - if (ImGui::Button(resetRayScattering.c_str())) env->ProceduralSkybox->RayleighScattering = Vector3(58e-7f, 135e-7f, 331e-7f); - ImGui::PopStyleColor(); - } - } - - if (env->CurrentSkyType == SkyType::ClearColor) - { - ImGui::TableNextColumn(); - - // Title - ImGui::Text("Clear color"); - ImGui::TableNextColumn(); - - // Color picker - ImGui::ColorEdit4("##clearColor", &env->AmbientColor.r, ImGuiColorEditFlags_NoAlpha); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetColor = ICON_FA_UNDO + std::string("##ResetColor"); - if (ImGui::Button(resetColor.c_str())) env->AmbientColor = Color(0, 0, 0, 1); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Ambient Term"); - ImGui::TableNextColumn(); - - // Here we create a dropdown for every sky type. - ImGui::DragFloat("##AmbientTerm", &env->AmbientTerm, 0.001f, 0.00f, 1.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string ResetType = ICON_FA_UNDO + std::string("##ambient"); - if (ImGui::Button(ResetType.c_str())) env->AmbientTerm = 0.25f; - ImGui::PopStyleColor(); - } - - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(TAA) - if (ImGui::BeginTable("EnvTableTAA", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - ImGui::TableNextColumn(); - { - auto& sceneRenderer = Engine::GetCurrentScene()->m_SceneRenderer; - - // Title - ImGui::Text("TAA Factor"); - ImGui::TableNextColumn(); - - ImGui::SliderFloat("##TAAFactor", &sceneRenderer->TAAFactor, 0.0f, 1.0f ); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetTAAFactor"); - if (ImGui::Button(resetVolumetric.c_str())) sceneRenderer->TAAFactor = 0.6f; - ImGui::PopStyleColor(); - } - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - BEGIN_COLLAPSE_HEADER(BLOOM) - if (ImGui::BeginTable("BloomTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Bloom"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##Enabled", &env->BloomEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloom = ICON_FA_UNDO + std::string("##resetBloom"); - if (ImGui::Button(resetBloom.c_str())) env->BloomEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Bloom Threshold"); - ImGui::TableNextColumn(); - - float threshold = env->mBloom->GetThreshold(); - ImGui::DragFloat("##Threshold", &threshold, 0.01f, 0.0f, 500.0f); - env->mBloom->SetThreshold(threshold); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetBloomThreshold"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Bloom Quality"); - ImGui::TableNextColumn(); - - int iteration = env->mBloom->GetIteration(); - int oldIteration = iteration; - ImGui::DragInt("##quality", &iteration, 1.0f, 0, 4); - - if (oldIteration != iteration) - { - env->mBloom->SetIteration(iteration); - } - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetQuality = ICON_FA_UNDO + std::string("##resetQuality"); - if (ImGui::Button(resetQuality.c_str())) env->mBloom->SetIteration(3); - ImGui::PopStyleColor(); - } - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(VOLUMETRIC) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Volumetric"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##VolumetricEnabled", &env->VolumetricEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Volumetric Scattering"); - ImGui::TableNextColumn(); - - float fogAmount = env->mVolumetric->GetFogAmount(); - ImGui::DragFloat("##Volumetric Scattering", &fogAmount, .001f, 0.f, 1.0f); - env->mVolumetric->SetFogAmount(fogAmount); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetBloomThreshold"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Volumetric Strength"); - ImGui::TableNextColumn(); - - float fogAmount = env->mVolumetric->GetFogExponant(); - ImGui::DragFloat("##Volumetric Strength", &fogAmount, .001f, 0.f, 1.0f); - env->mVolumetric->SetFogExponant(fogAmount); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetFogExpo"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Step count"); - ImGui::TableNextColumn(); - - int stepCount = env->mVolumetric->GetStepCount(); - ImGui::DragInt("##Volumetric Step Count", &stepCount, 1.f, 0.0f); - env->mVolumetric->SetStepCount(stepCount); - - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetQuality = ICON_FA_UNDO + std::string("##resetQuality"); - if (ImGui::Button(resetQuality.c_str())) env->VolumetricStepCount = 50.f; - ImGui::PopStyleColor(); - } - - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(SSAO) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##SSAOEnabled", &env->SSAOEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSSAO = ICON_FA_UNDO + std::string("##resetSSAO"); - if (ImGui::Button(resetSSAO.c_str())) env->SSAOEnabled = false; - ImGui::PopStyleColor(); - } - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO Strength"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##SSAOStrength", &env->mSSAO->Strength, 0.1f, 0.0f, 10.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetRadius = ICON_FA_UNDO + std::string("##resetStrength"); - if (ImGui::Button(resetRadius.c_str())) env->mSSAO->Strength = 2.0f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO Radius"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##SSAORadius", &env->mSSAO->Radius, 0.001f, 0.0f, 1.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetRadius = ICON_FA_UNDO + std::string("##resetRadius"); - if (ImGui::Button(resetRadius.c_str())) env->mSSAO->Radius = 0.5f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO Bias"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##SSAOBias", &env->mSSAO->Bias, 0.0001f, 0.0f, 0.5f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOBias"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Bias = 0.025f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO Area"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##SSAOArea", &env->mSSAO->Area, 0.0001f, 0.0f, 0.5f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOArea"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Area = 0.0075f; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("SSAO Falloff"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##SSAOFalloff", &env->mSSAO->Falloff, 0.0001f, 0.0f, 0.5f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOFalloff"); - if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Falloff = 0.0022f; - ImGui::PopStyleColor(); - } - - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(SSR) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3); - ImGui::TableSetupColumn("set", 0, 0.6); - ImGui::TableSetupColumn("reset", 0, 0.1); - - SSR* ssr = env->mSSR.get(); - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("SSR"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##SSREnabled", &env->SSREnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSSR = ICON_FA_UNDO + std::string("##resetSSR"); - if (ImGui::Button(resetSSR.c_str())) env->SSREnabled = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("SSR RayStep"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##SSRRS", &ssr->RayStep, 0.01f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("iterationCount"); - ImGui::TableNextColumn(); - ImGui::DragInt("##SSRRSi", &ssr->IterationCount, 1, 1); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("distanceBias"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##SSRRSid", &ssr->DistanceBias, 0.01f, 0.f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("sampleCount"); - ImGui::TableNextColumn(); - ImGui::DragInt("##SSRRSids", &ssr->SampleCount, 1, 0); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Sampling Enabled"); - ImGui::TableNextColumn(); - ImGui::Checkbox("##SSRRSidss", &ssr->SamplingEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Expo"); - ImGui::TableNextColumn(); - ImGui::Checkbox("##SSRRSidsse", &ssr->ExpoStep); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Adaptive Steps"); - ImGui::TableNextColumn(); - ImGui::Checkbox("##SSRRSidssse", &ssr->AdaptiveStep); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Binary Searcg"); - ImGui::TableNextColumn(); - ImGui::Checkbox("##SSRRSidsssbe", &ssr->BinarySearch); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("Debug"); - ImGui::TableNextColumn(); - ImGui::Checkbox("##SSRRSidsssbed", &ssr->DebugDraw); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - - ImGui::TableNextColumn(); - { - // Title - ImGui::Text("samplingCoefficient"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##samplingCoefficient", &ssr->SampleingCoefficient, 0.001f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; - ImGui::PopStyleColor(); - } - - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - - BEGIN_COLLAPSE_HEADER(DOF) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3); - ImGui::TableSetupColumn("set", 0, 0.6); - ImGui::TableSetupColumn("reset", 0, 0.1); - - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("DOF Enabled"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##dofEnabled", &env->DOFEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); - if (ImGui::Button(resetSSR.c_str())) env->DOFEnabled = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Focal Depth"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##doffocalDepth", &env->DOFFocalDepth); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetdofFocalDepth = ICON_FA_UNDO + std::string("##resetdofFocalDepth"); - if (ImGui::Button(resetdofFocalDepth.c_str())) env->DOFFocalDepth = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Focal Length"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##doffocalLength", &env->DOFFocalLength); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFFocalLength = ICON_FA_UNDO + std::string("##resetDOFFocalLength"); - if (ImGui::Button(resetDOFFocalLength.c_str())) env->DOFFocalLength = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("fStop"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##doffstop", &env->DOFFstop); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetDOFFstop"); - if (ImGui::Button(resetDOFFstop.c_str())) env->DOFFstop = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Auto focus"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##dofautofocus", &env->DOFAutoFocus); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetdofautofocus"); - if (ImGui::Button(resetDOFFstop.c_str())) env->DOFAutoFocus = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Display auto focus"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##dofshowautofocus", &env->DOFShowFocus); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFShowautofocus = ICON_FA_UNDO + std::string("##resetdofshowautofocus"); - if (ImGui::Button(resetDOFShowautofocus.c_str())) env->DOFShowFocus = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Manual focus"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##dofmanualfocus", &env->DOFManualFocus); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFShowautofocus = ICON_FA_UNDO + std::string("##resetdofshowautofocus"); - if (ImGui::Button(resetDOFShowautofocus.c_str())) env->DOFShowFocus = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("fStop"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##doffstop", &env->DOFFstop); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetDOFFstop"); - if (ImGui::Button(resetDOFFstop.c_str())) env->DOFFstop = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("DOF Start"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##dofstart", &env->DOFStart); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetdofstartp"); - if (ImGui::Button(resetDOFFstop.c_str())) env->DOFStart = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("DOF Distance"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##dofdistance", &env->DOFDist); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetDOFDist"); - if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("DOF Threshold"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##dofthreshold", &env->DOFThreshold, 0.001f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetDOFDist"); - if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("DOF Feather"); - ImGui::TableNextColumn(); - - ImGui::DragFloat("##doffeather", &env->DOFFeather, 0.001f, 0.0f, 1.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetdoffeather"); - if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; - ImGui::PopStyleColor(); - } - - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(BARREL_DISTORTION) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3f); - ImGui::TableSetupColumn("set", 0, 0.6f); - ImGui::TableSetupColumn("reset", 0, 0.1f); - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Barrel Distortion"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##BarrelEnabled", &env->BarrelDistortionEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); - if (ImGui::Button(resetSSR.c_str())) env->BarrelDistortionEnabled = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Distortion"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##distortion", &env->BarrelDistortion, 0.01f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->BarrelDistortion = 0.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Edge Distortion"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##edgedistortion", &env->BarrelEdgeDistortion, 0.01f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->BarrelEdgeDistortion = 0.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Scale Adjustement"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##barrelScale", &env->BarrelScale, 0.01f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->BarrelScale = 1.0f; - ImGui::PopStyleColor(); - } - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - - BEGIN_COLLAPSE_HEADER(VIGNETTE) - if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) - { - ImGui::TableSetupColumn("name", 0, 0.3); - ImGui::TableSetupColumn("set", 0, 0.6); - ImGui::TableSetupColumn("reset", 0, 0.1); - - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Vignette Enabled"); - ImGui::TableNextColumn(); - - ImGui::Checkbox("##VignetteEnabled", &env->VignetteEnabled); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); - if (ImGui::Button(resetSSR.c_str())) env->VignetteEnabled = false; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Intensity"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##vignetteIntensity", &env->VignetteIntensity, 0.1f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VignetteIntensity = 0.0f; - ImGui::PopStyleColor(); - } - - { - ImGui::TableNextColumn(); - // Title - ImGui::Text("Extend"); - ImGui::TableNextColumn(); - ImGui::DragFloat("##vignetteExtend", &env->VignetteExtend, 0.01f, 0.0f); - ImGui::TableNextColumn(); - - // Reset button - ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); - std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); - if (ImGui::Button(resetVolumetric.c_str())) env->VignetteExtend = 0.0f; - ImGui::PopStyleColor(); - } - ImGui::EndTable(); - } - END_COLLAPSE_HEADER() - } - ImGui::End(); std::string title = ICON_FA_TREE + std::string(" Hierarchy"); if (ImGui::Begin(title.c_str())) diff --git a/Editor/src/Windows/EditorSelectionPanel.cpp b/Editor/src/Windows/EditorSelectionPanel.cpp index afef0437..57ce25f6 100644 --- a/Editor/src/Windows/EditorSelectionPanel.cpp +++ b/Editor/src/Windows/EditorSelectionPanel.cpp @@ -73,6 +73,12 @@ void EditorSelectionPanel::ResolveFile(Ref file) Ref sky = ResourceLoader::LoadSky(currentFile->GetRelativePath()); selectedResource = sky; } + + if (currentFile->GetFileType() == FileType::Env) + { + Ref env = ResourceLoader::LoadEnvironment(currentFile->GetRelativePath()); + selectedResource = env; + } } void EditorSelectionPanel::Draw(EditorSelection selection, const std::string& id) @@ -454,6 +460,1046 @@ void EditorSelectionPanel::DrawFile(Ref file) } + break; + } + case FileType::Env: + { + const Ref env = std::static_pointer_cast(selectedResource); + std::string skyName = env->Path; + { + UIFont boldfont = UIFont(Fonts::SubTitle); + ImGui::Text(env->Path.c_str()); + + } + ImGui::SameLine(); + { + UIFont boldfont = UIFont(Fonts::Icons); + if (ImGui::Button(ICON_FA_SAVE)) + { + if (!ResourceManager::IsResourceLoaded(env->ID)) + { + ResourceManager::RegisterResource(env); + } + + std::string fileData = env->Serialize().dump(4); + + FileSystem::BeginWriteFile(env->Path); + FileSystem::WriteLine(fileData); + FileSystem::EndWriteFile(); + } + } + + BEGIN_COLLAPSE_HEADER(SKY); + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Sky Type"); + ImGui::TableNextColumn(); + + // Here we create a dropdown for every sky type. + const char* SkyTypes[] = { "Procedural Sky", "Color" }; + static int currentSkyType = (int)env->CurrentSkyType; + ImGui::Combo("##SkyType", ¤tSkyType, SkyTypes, IM_ARRAYSIZE(SkyTypes)); + env->CurrentSkyType = (SkyType)currentSkyType; + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); + if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Gamma"); + ImGui::TableNextColumn(); + + // Here we create a dropdown for every sky type. + ImGui::DragFloat("##gamma", &env->Gamma, 0.001f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); + if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Exposure"); + ImGui::TableNextColumn(); + + // Here we create a dropdown for every sky type. + ImGui::DragFloat("##exposure", &env->Exposure, 0.001f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string ResetType = ICON_FA_UNDO + std::string("##ResetType"); + if (ImGui::Button(ResetType.c_str())) env->CurrentSkyType = SkyType::ProceduralSky; + ImGui::PopStyleColor(); + } + + if (env->CurrentSkyType == SkyType::ProceduralSky) + { + ImGui::TableNextColumn(); + + { // Sun Intensity + ImGui::Text("Sun Intensity"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##Sun Intensity", &env->ProceduralSkybox->SunIntensity, 0.1f, 0.0f, 1000.0f); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSunIntensity = ICON_FA_UNDO + std::string("##ResetSunIntensity"); + if (ImGui::Button(resetSunIntensity.c_str())) env->ProceduralSkybox->SunIntensity = 100.0f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // Sun Direction + ImGui::Text("Sun Direction"); + ImGui::TableNextColumn(); + + Vector3 sunDirection = env->ProceduralSkybox->GetSunDirection(); + ImGuiHelper::DrawVec3("##Sun Direction", &sunDirection); + env->ProceduralSkybox->SunDirection = glm::mix(env->ProceduralSkybox->GetSunDirection(), glm::normalize(sunDirection), 0.1f); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSunDirection = ICON_FA_UNDO + std::string("##resetSunDirection"); + if (ImGui::Button(resetSunDirection.c_str())) env->ProceduralSkybox->SunDirection = Vector3(0.20000f, 0.95917f, 0.20000f); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // Surface Radius + ImGui::Text("Surface Radius"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##surfaceRadius", &env->ProceduralSkybox->SurfaceRadius, 100.f, 0.0f); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSurfaceRadius = ICON_FA_UNDO + std::string("##resetSurfaceRadius"); + if (ImGui::Button(resetSurfaceRadius.c_str())) env->ProceduralSkybox->SurfaceRadius = 6360e3f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // Atmosphere Radius + ImGui::Text("Atmosphere Radius"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##AtmosphereRadius", &env->ProceduralSkybox->AtmosphereRadius, 100.f, 0.0f); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetAtmosphereRadius = ICON_FA_UNDO + std::string("##resetAtmosphereRadius"); + if (ImGui::Button(resetAtmosphereRadius.c_str())) env->ProceduralSkybox->AtmosphereRadius = 6380e3f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // Center point + ImGui::Text("Center Point"); + ImGui::TableNextColumn(); + + ImGuiHelper::DrawVec3("##Center Point", &env->ProceduralSkybox->CenterPoint, 0.0f, 100.0f, 100.0f); + ImGui::TableNextColumn(); + if (env->ProceduralSkybox->CenterPoint.y < -env->ProceduralSkybox->AtmosphereRadius) + env->ProceduralSkybox->CenterPoint.y = -env->ProceduralSkybox->AtmosphereRadius + 1.f; + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetCenterPoint = ICON_FA_UNDO + std::string("##resetAtmosphereRadius"); + if (ImGui::Button(resetCenterPoint.c_str())) env->ProceduralSkybox->CenterPoint = Vector3(0, -env->ProceduralSkybox->AtmosphereRadius, 0); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // Mie Scattering + ImGui::Text("Mie Scattering"); + ImGui::TableNextColumn(); + + Vector3 mieScattering = env->ProceduralSkybox->MieScattering * 10000.0f; + ImGuiHelper::DrawVec3("##Mie Scattering", &mieScattering, 0.0f, 100.0f, 0.01f); + if (mieScattering.x < 0) mieScattering.x = 0; + if (mieScattering.y < 0) mieScattering.y = 0; + if (mieScattering.z < 0) mieScattering.z = 0; + env->ProceduralSkybox->MieScattering = mieScattering / 10000.0f; + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetMieScattering = ICON_FA_UNDO + std::string("##resetMieScattering"); + if (ImGui::Button(resetMieScattering.c_str())) env->ProceduralSkybox->MieScattering = Vector3(2e-5f); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { // RayleighScattering + ImGui::Text("Rayleigh Scattering"); + ImGui::TableNextColumn(); + + Vector3 rayleighScattering = env->ProceduralSkybox->RayleighScattering * 10000.0f; + ImGuiHelper::DrawVec3("##Ray Scattering", &rayleighScattering, 0.0f, 100.0f, 0.01f); + if (rayleighScattering.r < 0) rayleighScattering.r = 0; + if (rayleighScattering.g < 0) rayleighScattering.g = 0; + if (rayleighScattering.b < 0) rayleighScattering.b = 0; + env->ProceduralSkybox->RayleighScattering = rayleighScattering / 10000.0f; + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetRayScattering = ICON_FA_UNDO + std::string("##resetRayScattering"); + if (ImGui::Button(resetRayScattering.c_str())) env->ProceduralSkybox->RayleighScattering = Vector3(58e-7f, 135e-7f, 331e-7f); + ImGui::PopStyleColor(); + } + } + + if (env->CurrentSkyType == SkyType::ClearColor) + { + ImGui::TableNextColumn(); + + // Title + ImGui::Text("Clear color"); + ImGui::TableNextColumn(); + + // Color picker + ImGui::ColorEdit4("##clearColor", &env->AmbientColor.r, ImGuiColorEditFlags_NoAlpha); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetColor = ICON_FA_UNDO + std::string("##ResetColor"); + if (ImGui::Button(resetColor.c_str())) env->AmbientColor = Color(0, 0, 0, 1); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Ambient Term"); + ImGui::TableNextColumn(); + + // Here we create a dropdown for every sky type. + ImGui::DragFloat("##AmbientTerm", &env->AmbientTerm, 0.001f, 0.00f, 1.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string ResetType = ICON_FA_UNDO + std::string("##ambient"); + if (ImGui::Button(ResetType.c_str())) env->AmbientTerm = 0.25f; + ImGui::PopStyleColor(); + } + + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(TAA) + if (ImGui::BeginTable("EnvTableTAA", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + ImGui::TableNextColumn(); + { + auto& sceneRenderer = Engine::GetCurrentScene()->m_SceneRenderer; + + // Title + ImGui::Text("TAA Factor"); + ImGui::TableNextColumn(); + + ImGui::SliderFloat("##TAAFactor", &sceneRenderer->TAAFactor, 0.0f, 1.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetTAAFactor"); + if (ImGui::Button(resetVolumetric.c_str())) sceneRenderer->TAAFactor = 0.6f; + ImGui::PopStyleColor(); + } + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + BEGIN_COLLAPSE_HEADER(BLOOM) + if (ImGui::BeginTable("BloomTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Bloom"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##Enabled", &env->BloomEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloom = ICON_FA_UNDO + std::string("##resetBloom"); + if (ImGui::Button(resetBloom.c_str())) env->BloomEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Bloom Threshold"); + ImGui::TableNextColumn(); + + float threshold = env->mBloom->GetThreshold(); + ImGui::DragFloat("##Threshold", &threshold, 0.01f, 0.0f, 500.0f); + env->mBloom->SetThreshold(threshold); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetBloomThreshold"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Bloom Quality"); + ImGui::TableNextColumn(); + + int iteration = env->mBloom->GetIteration(); + int oldIteration = iteration; + ImGui::DragInt("##quality", &iteration, 1.0f, 0, 4); + + if (oldIteration != iteration) + { + env->mBloom->SetIteration(iteration); + } + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetQuality = ICON_FA_UNDO + std::string("##resetQuality"); + if (ImGui::Button(resetQuality.c_str())) env->mBloom->SetIteration(3); + ImGui::PopStyleColor(); + } + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(VOLUMETRIC) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Volumetric"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##VolumetricEnabled", &env->VolumetricEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Volumetric Scattering"); + ImGui::TableNextColumn(); + + float fogAmount = env->mVolumetric->GetFogAmount(); + ImGui::DragFloat("##Volumetric Scattering", &fogAmount, .001f, 0.f, 1.0f); + env->mVolumetric->SetFogAmount(fogAmount); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetBloomThreshold"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Volumetric Strength"); + ImGui::TableNextColumn(); + + float fogAmount = env->mVolumetric->GetFogExponant(); + ImGui::DragFloat("##Volumetric Strength", &fogAmount, .001f, 0.f, 1.0f); + env->mVolumetric->SetFogExponant(fogAmount); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetFogExpo"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mBloom->SetThreshold(2.4f); + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Step count"); + ImGui::TableNextColumn(); + + int stepCount = env->mVolumetric->GetStepCount(); + ImGui::DragInt("##Volumetric Step Count", &stepCount, 1.f, 0.0f); + env->mVolumetric->SetStepCount(stepCount); + + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetQuality = ICON_FA_UNDO + std::string("##resetQuality"); + if (ImGui::Button(resetQuality.c_str())) env->VolumetricStepCount = 50.f; + ImGui::PopStyleColor(); + } + + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(SSAO) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##SSAOEnabled", &env->SSAOEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSSAO = ICON_FA_UNDO + std::string("##resetSSAO"); + if (ImGui::Button(resetSSAO.c_str())) env->SSAOEnabled = false; + ImGui::PopStyleColor(); + } + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO Strength"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##SSAOStrength", &env->mSSAO->Strength, 0.1f, 0.0f, 10.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetRadius = ICON_FA_UNDO + std::string("##resetStrength"); + if (ImGui::Button(resetRadius.c_str())) env->mSSAO->Strength = 2.0f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO Radius"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##SSAORadius", &env->mSSAO->Radius, 0.001f, 0.0f, 1.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetRadius = ICON_FA_UNDO + std::string("##resetRadius"); + if (ImGui::Button(resetRadius.c_str())) env->mSSAO->Radius = 0.5f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO Bias"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##SSAOBias", &env->mSSAO->Bias, 0.0001f, 0.0f, 0.5f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOBias"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Bias = 0.025f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO Area"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##SSAOArea", &env->mSSAO->Area, 0.0001f, 0.0f, 0.5f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOArea"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Area = 0.0075f; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("SSAO Falloff"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##SSAOFalloff", &env->mSSAO->Falloff, 0.0001f, 0.0f, 0.5f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetBloomThreshold = ICON_FA_UNDO + std::string("##resetSSAOFalloff"); + if (ImGui::Button(resetBloomThreshold.c_str())) env->mSSAO->Falloff = 0.0022f; + ImGui::PopStyleColor(); + } + + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(SSR) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3); + ImGui::TableSetupColumn("set", 0, 0.6); + ImGui::TableSetupColumn("reset", 0, 0.1); + + SSR* ssr = env->mSSR.get(); + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("SSR"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##SSREnabled", &env->SSREnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSSR = ICON_FA_UNDO + std::string("##resetSSR"); + if (ImGui::Button(resetSSR.c_str())) env->SSREnabled = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("SSR RayStep"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##SSRRS", &ssr->RayStep, 0.01f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("iterationCount"); + ImGui::TableNextColumn(); + ImGui::DragInt("##SSRRSi", &ssr->IterationCount, 1, 1); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("distanceBias"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##SSRRSid", &ssr->DistanceBias, 0.01f, 0.f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("sampleCount"); + ImGui::TableNextColumn(); + ImGui::DragInt("##SSRRSids", &ssr->SampleCount, 1, 0); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Sampling Enabled"); + ImGui::TableNextColumn(); + ImGui::Checkbox("##SSRRSidss", &ssr->SamplingEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Expo"); + ImGui::TableNextColumn(); + ImGui::Checkbox("##SSRRSidsse", &ssr->ExpoStep); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Adaptive Steps"); + ImGui::TableNextColumn(); + ImGui::Checkbox("##SSRRSidssse", &ssr->AdaptiveStep); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Binary Searcg"); + ImGui::TableNextColumn(); + ImGui::Checkbox("##SSRRSidsssbe", &ssr->BinarySearch); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("Debug"); + ImGui::TableNextColumn(); + ImGui::Checkbox("##SSRRSidsssbed", &ssr->DebugDraw); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + + ImGui::TableNextColumn(); + { + // Title + ImGui::Text("samplingCoefficient"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##samplingCoefficient", &ssr->SampleingCoefficient, 0.001f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VolumetricEnabled = false; + ImGui::PopStyleColor(); + } + + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + + BEGIN_COLLAPSE_HEADER(DOF) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3); + ImGui::TableSetupColumn("set", 0, 0.6); + ImGui::TableSetupColumn("reset", 0, 0.1); + + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("DOF Enabled"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##dofEnabled", &env->DOFEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); + if (ImGui::Button(resetSSR.c_str())) env->DOFEnabled = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Focal Depth"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##doffocalDepth", &env->DOFFocalDepth); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetdofFocalDepth = ICON_FA_UNDO + std::string("##resetdofFocalDepth"); + if (ImGui::Button(resetdofFocalDepth.c_str())) env->DOFFocalDepth = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Focal Length"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##doffocalLength", &env->DOFFocalLength); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFFocalLength = ICON_FA_UNDO + std::string("##resetDOFFocalLength"); + if (ImGui::Button(resetDOFFocalLength.c_str())) env->DOFFocalLength = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("fStop"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##doffstop", &env->DOFFstop); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetDOFFstop"); + if (ImGui::Button(resetDOFFstop.c_str())) env->DOFFstop = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Auto focus"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##dofautofocus", &env->DOFAutoFocus); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetdofautofocus"); + if (ImGui::Button(resetDOFFstop.c_str())) env->DOFAutoFocus = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Display auto focus"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##dofshowautofocus", &env->DOFShowFocus); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFShowautofocus = ICON_FA_UNDO + std::string("##resetdofshowautofocus"); + if (ImGui::Button(resetDOFShowautofocus.c_str())) env->DOFShowFocus = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Manual focus"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##dofmanualfocus", &env->DOFManualFocus); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFShowautofocus = ICON_FA_UNDO + std::string("##resetdofshowautofocus"); + if (ImGui::Button(resetDOFShowautofocus.c_str())) env->DOFShowFocus = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("fStop"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##doffstop", &env->DOFFstop); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetDOFFstop"); + if (ImGui::Button(resetDOFFstop.c_str())) env->DOFFstop = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("DOF Start"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##dofstart", &env->DOFStart); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFFstop = ICON_FA_UNDO + std::string("##resetdofstartp"); + if (ImGui::Button(resetDOFFstop.c_str())) env->DOFStart = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("DOF Distance"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##dofdistance", &env->DOFDist); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetDOFDist"); + if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("DOF Threshold"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##dofthreshold", &env->DOFThreshold, 0.001f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetDOFDist"); + if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("DOF Feather"); + ImGui::TableNextColumn(); + + ImGui::DragFloat("##doffeather", &env->DOFFeather, 0.001f, 0.0f, 1.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDOFDist = ICON_FA_UNDO + std::string("##resetdoffeather"); + if (ImGui::Button(resetDOFDist.c_str())) env->DOFDist = 1.0f; + ImGui::PopStyleColor(); + } + + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(BARREL_DISTORTION) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3f); + ImGui::TableSetupColumn("set", 0, 0.6f); + ImGui::TableSetupColumn("reset", 0, 0.1f); + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Barrel Distortion"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##BarrelEnabled", &env->BarrelDistortionEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); + if (ImGui::Button(resetSSR.c_str())) env->BarrelDistortionEnabled = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Distortion"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##distortion", &env->BarrelDistortion, 0.01f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->BarrelDistortion = 0.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Edge Distortion"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##edgedistortion", &env->BarrelEdgeDistortion, 0.01f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->BarrelEdgeDistortion = 0.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Scale Adjustement"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##barrelScale", &env->BarrelScale, 0.01f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->BarrelScale = 1.0f; + ImGui::PopStyleColor(); + } + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() + + BEGIN_COLLAPSE_HEADER(VIGNETTE) + if (ImGui::BeginTable("EnvTable", 3, ImGuiTableFlags_BordersInner | ImGuiTableFlags_SizingStretchProp)) + { + ImGui::TableSetupColumn("name", 0, 0.3); + ImGui::TableSetupColumn("set", 0, 0.6); + ImGui::TableSetupColumn("reset", 0, 0.1); + + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Vignette Enabled"); + ImGui::TableNextColumn(); + + ImGui::Checkbox("##VignetteEnabled", &env->VignetteEnabled); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetSSR = ICON_FA_UNDO + std::string("##resetrBarrelDistortionEnabled"); + if (ImGui::Button(resetSSR.c_str())) env->VignetteEnabled = false; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Intensity"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##vignetteIntensity", &env->VignetteIntensity, 0.1f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VignetteIntensity = 0.0f; + ImGui::PopStyleColor(); + } + + { + ImGui::TableNextColumn(); + // Title + ImGui::Text("Extend"); + ImGui::TableNextColumn(); + ImGui::DragFloat("##vignetteExtend", &env->VignetteExtend, 0.01f, 0.0f); + ImGui::TableNextColumn(); + + // Reset button + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetVolumetric = ICON_FA_UNDO + std::string("##resetVolumetric"); + if (ImGui::Button(resetVolumetric.c_str())) env->VignetteExtend = 0.0f; + ImGui::PopStyleColor(); + } + ImGui::EndTable(); + } + END_COLLAPSE_HEADER() break; } } diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index c7cf77dd..a5e5e8a9 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -333,6 +333,10 @@ namespace Nuake { dragType = "_SkyFile"; } + else if (fileExtension == ".env") + { + dragType = "_EnvFile"; + } ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer)); ImGui::Text(file->GetName().c_str()); @@ -401,6 +405,10 @@ namespace Nuake { textureImage = textureMgr->GetTexture("Resources/Images/trenchbroom_icon.png"); } + else if (fileType == FileType::Env) + { + textureImage = textureMgr->GetTexture("Resources/Images/env_file_icon.png"); + } ImGui::SetCursorPos(prevCursor); ImGui::Image(reinterpret_cast(textureImage->GetID()), ImVec2(100, 100), ImVec2(0, 1), ImVec2(1, 0)); @@ -698,6 +706,28 @@ namespace Nuake FileSystem::WriteLine(jsonData.dump(4)); FileSystem::EndWriteFile(); + RefreshFileBrowser(); + } + } + if (ImGui::MenuItem("Environment")) + { + const std::string path = FileDialog::SaveFile("*.env"); + if (!path.empty()) + { + std::string finalPath = path; + if (!String::EndsWith(path, ".env")) + { + finalPath = path + ".env"; + } + + Ref env = CreateRef(FileSystem::AbsoluteToRelative(finalPath)); + env->IsEmbedded = false; + auto jsonData = env->Serialize(); + + FileSystem::BeginWriteFile(finalPath, true); + FileSystem::WriteLine(jsonData.dump(4)); + FileSystem::EndWriteFile(); + RefreshFileBrowser(); } } diff --git a/Nuake/src/Core/RegisterCoreTypes.cpp b/Nuake/src/Core/RegisterCoreTypes.cpp index 697d1f8a..5ec8e078 100644 --- a/Nuake/src/Core/RegisterCoreTypes.cpp +++ b/Nuake/src/Core/RegisterCoreTypes.cpp @@ -19,6 +19,8 @@ #include "src/Scene/Components/SpriteComponent.h" #include "src/Scene/Components/UIComponent.h" #include "src/Scene/Components/SkyComponent.h" +#include "src/Scene/Components/EnvironmentComponent.h" + namespace Nuake { @@ -44,6 +46,7 @@ namespace Nuake BoneComponent::InternalInitializeClass(); AudioEmitterComponent::InternalInitializeClass(); SkyComponent::InternalInitializeClass(); + EnvironmentComponent::InternalInitializeClass(); } } diff --git a/Nuake/src/FileSystem/File.cpp b/Nuake/src/FileSystem/File.cpp index 5d00b4c5..6df0fb95 100644 --- a/Nuake/src/FileSystem/File.cpp +++ b/Nuake/src/FileSystem/File.cpp @@ -99,6 +99,11 @@ FileType File::GetFileType() const return FileType::Sky; } + if (ext == ".env") + { + return FileType::Env; + } + return FileType::Unknown; } @@ -170,6 +175,11 @@ std::string File::GetFileTypeAsString() const return "Sky"; } + if (ext == ".env") + { + return "Environment"; + } + return "File"; } diff --git a/Nuake/src/FileSystem/FileTypes.h b/Nuake/src/FileSystem/FileTypes.h index 5c50ede9..b1335e31 100644 --- a/Nuake/src/FileSystem/FileTypes.h +++ b/Nuake/src/FileSystem/FileTypes.h @@ -21,6 +21,7 @@ namespace Nuake Audio, UI, CSS, - Sky + Sky, + Env }; } diff --git a/Nuake/src/Rendering/Textures/TextureManager.cpp b/Nuake/src/Rendering/Textures/TextureManager.cpp index 16d93b2f..c5efee05 100644 --- a/Nuake/src/Rendering/Textures/TextureManager.cpp +++ b/Nuake/src/Rendering/Textures/TextureManager.cpp @@ -34,6 +34,7 @@ namespace Nuake m_Registry.emplace(Resources_Images_logo_white_png_path, CreateRef(Resources_Images_logo_white_png, Resources_Images_logo_white_png_len)); m_Registry.emplace(Resources_Images_logo_png_path, CreateRef(Resources_Images_logo_png, Resources_Images_logo_png_len)); m_Registry.emplace(Resources_Images_file_icon_png_path, CreateRef(Resources_Images_file_icon_png, Resources_Images_file_icon_png_len)); + m_Registry.emplace(Resources_Images_env_file_icon_png_path, CreateRef(Resources_Images_env_file_icon_png, Resources_Images_env_file_icon_png_len)); m_Registry.emplace(Resources_Images_scene_icon_png_path, CreateRef(Resources_Images_scene_icon_png, Resources_Images_scene_icon_png_len)); m_Registry.emplace(Resources_Images_project_icon_png_path, CreateRef(Resources_Images_project_icon_png, Resources_Images_project_icon_png_len)); m_Registry.emplace(Resources_Images_csharp_icon_png_path, CreateRef(Resources_Images_csharp_icon_png, Resources_Images_csharp_icon_png_len)); diff --git a/Nuake/src/Resource/ResourceLoader.cpp b/Nuake/src/Resource/ResourceLoader.cpp index b9534e1a..78661e67 100644 --- a/Nuake/src/Resource/ResourceLoader.cpp +++ b/Nuake/src/Resource/ResourceLoader.cpp @@ -8,6 +8,8 @@ #include "src/Resource/Model.h" #include "src/Resource/UI.h" #include "src/Resource/SkyResource.h" +#include "src/Scene/Lighting/Environment.h" + using namespace Nuake; Ref ResourceLoader::LoadMaterial(const std::string& path) @@ -139,6 +141,51 @@ Ref ResourceLoader::LoadSky(const std::string& path) return sky; } +Ref ResourceLoader::LoadEnvironment(const std::string& path) +{ + const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; + const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; + const std::string ENV_EXT = ".env"; + + if (path.empty()) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!FileSystem::FileExists(path)) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!String::EndsWith(path, ENV_EXT)) + { + std::string message = WRONG_EXTENSION + ENV_EXT + " actual: " + path; + Logger::Log(message, "resource", LOG_TYPE::WARNING); + } + + std::string content = FileSystem::ReadFile(path); + json j = json::parse(content); + + UUID uuid = ReadUUID(j); + + // Check if resource is already loaded. + if (ResourceManager::IsResourceLoaded(uuid)) + { + return ResourceManager::GetResource(uuid); + } + + Ref env = CreateRef(); + env->ID = uuid; + env->Path = path; + env->Deserialize(j); + ResourceManager::RegisterResource(env); + + return env; +} + + Ref ResourceLoader::LoadUI(const std::string& path) { auto uiResource = CreateRef(path); diff --git a/Nuake/src/Resource/ResourceLoader.h b/Nuake/src/Resource/ResourceLoader.h index f9d63615..5de62f83 100644 --- a/Nuake/src/Resource/ResourceLoader.h +++ b/Nuake/src/Resource/ResourceLoader.h @@ -10,6 +10,7 @@ namespace Nuake class UIResource; class File; class SkyResource; + class Environment; class ResourceLoader { @@ -25,6 +26,7 @@ namespace Nuake static Ref LoadMaterial(const std::string& path); static Ref LoadModel(const std::string& path); static Ref LoadSky(const std::string& path); + static Ref LoadEnvironment(const std::string& path); static Ref LoadUI(const std::string& path); static Ref LoadUI(const Ref& file); diff --git a/Nuake/src/Resource/StaticResources.cpp b/Nuake/src/Resource/StaticResources.cpp index e81d9d0e..1e5e6e4e 100644 --- a/Nuake/src/Resource/StaticResources.cpp +++ b/Nuake/src/Resource/StaticResources.cpp @@ -140658,6 +140658,95 @@ namespace Nuake { }; unsigned int Resources_Images_editor_icon_png_len = sizeof(Resources_Images_editor_icon_png); + // Data for file: Resources_Images_env_file_icon_png_path + const std::string Resources_Images_env_file_icon_png_path = R"(Resources/Images/env_file_icon.png)"; + unsigned char Resources_Images_env_file_icon_png[] = { + 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, + 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, + 0x08, 0x06, 0x00, 0x00, 0x00, 0x70, 0xE2, 0x95, 0x54, 0x00, 0x00, 0x00, + 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0B, 0x13, 0x00, 0x00, 0x0B, + 0x13, 0x01, 0x00, 0x9A, 0x9C, 0x18, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, + 0x47, 0x42, 0x00, 0xAE, 0xCE, 0x1C, 0xE9, 0x00, 0x00, 0x00, 0x04, 0x67, + 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61, 0x05, 0x00, + 0x00, 0x03, 0x6E, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0xED, 0xDB, 0x8D, + 0x51, 0xDB, 0x30, 0x14, 0xC0, 0xF1, 0x97, 0x5E, 0x07, 0x60, 0x83, 0x7A, + 0x83, 0x66, 0x83, 0x86, 0x09, 0xDA, 0x0D, 0x92, 0x4E, 0x00, 0x1B, 0x90, + 0x4E, 0x00, 0x1B, 0x38, 0x4C, 0x40, 0x37, 0x70, 0x37, 0x80, 0x0D, 0xCC, + 0x06, 0xB0, 0xC1, 0xAB, 0x74, 0x96, 0x1B, 0x59, 0xFE, 0x92, 0x8D, 0x8B, + 0x4D, 0xF2, 0xFF, 0xDD, 0xE9, 0x72, 0x18, 0x59, 0xB9, 0x7B, 0xCF, 0x92, + 0x25, 0xD9, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x64, 0x25, + 0x1F, 0x9C, 0xAA, 0x5E, 0x98, 0x8F, 0x0B, 0xF7, 0xE7, 0xEB, 0x6A, 0xB5, + 0x7A, 0x95, 0x11, 0x4C, 0x3B, 0x89, 0x39, 0xF7, 0x59, 0x30, 0x8C, 0x09, + 0xDC, 0xC6, 0x94, 0x5B, 0x53, 0x1E, 0x4D, 0x79, 0xD1, 0x3A, 0x7B, 0x2C, + 0x73, 0x75, 0x36, 0x91, 0x6D, 0xEE, 0xDD, 0xB9, 0x99, 0xA0, 0x9F, 0xED, + 0x05, 0x2E, 0x68, 0x4D, 0x09, 0xE8, 0x93, 0x9B, 0xB2, 0xED, 0x68, 0x7B, + 0xEF, 0xD7, 0x95, 0x99, 0x2D, 0x7E, 0xC8, 0x32, 0x41, 0xBA, 0x36, 0x1F, + 0x37, 0x72, 0x1C, 0x96, 0x7C, 0x07, 0x53, 0x5E, 0x5D, 0x29, 0xAD, 0x5D, + 0x49, 0x82, 0xBA, 0xCF, 0xA6, 0xEC, 0xCD, 0xB0, 0x74, 0xEF, 0xB5, 0xBD, + 0x77, 0x6D, 0x8B, 0x6B, 0xE3, 0xD2, 0xFC, 0xFF, 0x49, 0x50, 0x67, 0xC7, + 0x74, 0x37, 0xF4, 0xB4, 0xD9, 0x46, 0x9C, 0x7F, 0xE5, 0x7A, 0x88, 0x2F, + 0xF5, 0x7A, 0x5C, 0xC9, 0xF6, 0xBC, 0xB5, 0xA0, 0x99, 0x0D, 0x4E, 0x43, + 0x20, 0xA3, 0x93, 0xD1, 0xD0, 0xDE, 0x2E, 0x68, 0xEF, 0x85, 0x64, 0x44, + 0x72, 0x57, 0x76, 0xD7, 0xBD, 0x62, 0x54, 0x00, 0xB5, 0xB9, 0xC7, 0x91, + 0x8C, 0x2E, 0x2E, 0x68, 0xB9, 0xF6, 0x1B, 0x1D, 0x48, 0x2D, 0x66, 0x5F, + 0xA5, 0x5C, 0x8B, 0x69, 0x33, 0x9A, 0x68, 0x31, 0x95, 0x8D, 0x65, 0x93, + 0x62, 0xEF, 0x11, 0x3B, 0x57, 0xA2, 0x03, 0x1B, 0x24, 0xE5, 0x56, 0x50, + 0x67, 0x02, 0x73, 0xAD, 0x6F, 0xF3, 0x38, 0x30, 0x29, 0x99, 0x77, 0xEE, + 0x46, 0x70, 0xA4, 0xF1, 0x43, 0xD5, 0x64, 0x49, 0xD1, 0xEA, 0xBD, 0x6A, + 0xF6, 0xF5, 0x47, 0xE9, 0x93, 0x2C, 0xC3, 0x4E, 0xEA, 0xEB, 0x86, 0x31, + 0x12, 0x89, 0x6C, 0xC7, 0x6D, 0x93, 0xDC, 0x95, 0xE7, 0xE9, 0xC0, 0x99, + 0xDB, 0x49, 0xF3, 0x7A, 0x47, 0xAE, 0xE3, 0x56, 0xE3, 0xAA, 0x23, 0x6E, + 0xF4, 0x5A, 0xAC, 0x47, 0xCA, 0xEF, 0x63, 0xDB, 0xC4, 0xD2, 0x62, 0x6F, + 0xAA, 0xB4, 0xD5, 0x62, 0x0D, 0x32, 0x34, 0x29, 0x53, 0xCD, 0xBA, 0xBE, + 0xC8, 0xB9, 0x0B, 0x02, 0x92, 0xB8, 0x63, 0x43, 0x92, 0xF2, 0xA6, 0xB5, + 0x44, 0x70, 0x41, 0x5C, 0xC9, 0xB9, 0xD3, 0xE3, 0x6C, 0xE7, 0x31, 0x38, + 0x1E, 0x93, 0x94, 0x49, 0x16, 0x76, 0xDE, 0xF7, 0xA4, 0x72, 0xEE, 0xBC, + 0x60, 0x3C, 0x34, 0xFC, 0x6F, 0xD7, 0x90, 0x84, 0x54, 0x8B, 0xA1, 0x6D, + 0xAB, 0x13, 0xAD, 0xB2, 0xF5, 0xB8, 0xFE, 0x99, 0x7D, 0xB6, 0xF5, 0x59, + 0x66, 0xA4, 0xD5, 0x87, 0x4B, 0x31, 0xBB, 0xAC, 0x07, 0x33, 0x3B, 0xFA, + 0x29, 0xD3, 0xB3, 0xDF, 0xBD, 0x96, 0xE6, 0x1D, 0xE5, 0x77, 0x35, 0xF7, + 0xB4, 0x77, 0x48, 0x00, 0xFE, 0x98, 0xF2, 0x4B, 0xFF, 0xEF, 0x56, 0xC7, + 0xD9, 0x27, 0x64, 0x88, 0x8D, 0x29, 0x76, 0x48, 0xB1, 0x43, 0xDC, 0xC9, + 0xAE, 0x19, 0xE6, 0x4E, 0x88, 0xFF, 0x60, 0x69, 0xC8, 0xD5, 0x79, 0x98, + 0x38, 0x29, 0xFF, 0x9E, 0xC9, 0xCB, 0xCC, 0x66, 0xBD, 0x87, 0xD8, 0x17, + 0x12, 0x4C, 0x60, 0x6D, 0x10, 0xFC, 0x7B, 0x89, 0xCF, 0x8E, 0xED, 0xFB, + 0xE0, 0x58, 0x22, 0xC5, 0xCA, 0xFE, 0xE0, 0x6E, 0xEA, 0x5D, 0x41, 0xBC, + 0x8F, 0x7C, 0x71, 0xA1, 0xFC, 0xEE, 0x98, 0xBA, 0xA7, 0xCD, 0x9B, 0xF6, + 0x46, 0xCD, 0x70, 0x82, 0x75, 0x43, 0x9F, 0x5C, 0xDD, 0xDA, 0xA6, 0xA7, + 0x4D, 0x6D, 0x9B, 0xE9, 0xBD, 0xB7, 0x25, 0xDC, 0x43, 0xCA, 0xD9, 0x95, + 0xDD, 0x4F, 0x9A, 0x7A, 0xA5, 0x9C, 0x98, 0x92, 0x75, 0x25, 0x45, 0xAB, + 0x3B, 0xBD, 0xBF, 0xE5, 0xDC, 0x05, 0x57, 0xFC, 0x4D, 0x44, 0xFD, 0x0B, + 0x1D, 0xF6, 0xDC, 0xC4, 0x4A, 0x3B, 0xDA, 0x4B, 0xBD, 0x7A, 0x89, 0xA0, + 0xB2, 0x38, 0xB4, 0x9F, 0xBD, 0x37, 0xF7, 0x11, 0x49, 0x49, 0x5B, 0xDA, + 0x49, 0xBC, 0x3A, 0x8B, 0xD8, 0x5C, 0x5C, 0xCA, 0xB4, 0xB7, 0xDC, 0x06, + 0xB7, 0xC9, 0xE8, 0xDD, 0x4F, 0x72, 0x6F, 0x27, 0x5E, 0x4A, 0xDC, 0x62, + 0xD2, 0x6A, 0xBB, 0xF1, 0xFB, 0x3D, 0xF2, 0x20, 0x28, 0x68, 0x75, 0x1B, + 0xFC, 0x25, 0x76, 0xE8, 0x08, 0x86, 0x9B, 0x36, 0x8D, 0x0F, 0xAD, 0x82, + 0xDE, 0xB1, 0x98, 0x07, 0x54, 0x8B, 0x61, 0x82, 0xF2, 0x63, 0xE8, 0xF0, + 0x11, 0x91, 0x90, 0xB6, 0x64, 0xD8, 0x0B, 0x20, 0xF7, 0xEA, 0x7D, 0x15, + 0xD4, 0x99, 0xC0, 0x3C, 0x78, 0x41, 0xEA, 0x7D, 0xF9, 0xA0, 0x27, 0x21, + 0xAD, 0x8F, 0x73, 0xB5, 0xFA, 0x3C, 0xBD, 0x77, 0x22, 0x71, 0xB6, 0xB4, + 0x3A, 0x74, 0xF5, 0x26, 0xA5, 0x23, 0x21, 0x5D, 0x3D, 0x23, 0xF3, 0xEB, + 0x09, 0xDA, 0x69, 0xF5, 0xF5, 0x4E, 0x3F, 0xB8, 0x49, 0x4B, 0xFD, 0x5B, + 0x37, 0xF4, 0xF8, 0x25, 0x6B, 0x49, 0x46, 0xF8, 0x36, 0x64, 0xAE, 0x4C, + 0x73, 0xDB, 0x69, 0xFD, 0x5D, 0xDB, 0x3C, 0x48, 0xCC, 0x7E, 0x4C, 0x00, + 0x5D, 0xAF, 0xB8, 0x8B, 0xE9, 0x41, 0x70, 0x1A, 0x92, 0xB1, 0x76, 0x81, + 0x4C, 0x83, 0x40, 0xE6, 0xEE, 0xD8, 0xA6, 0xA7, 0x3D, 0x7B, 0xEE, 0xC6, + 0xF5, 0xA0, 0xF0, 0xA9, 0x23, 0x2F, 0xC6, 0x75, 0xD1, 0x9E, 0xB7, 0xD0, + 0xB5, 0xFE, 0xA2, 0xB4, 0x5F, 0x37, 0xD3, 0x62, 0x22, 0x90, 0x7A, 0xA5, + 0xED, 0x87, 0x3C, 0xB6, 0xEE, 0x37, 0x41, 0x3B, 0x77, 0x25, 0xB7, 0x26, + 0x23, 0xA8, 0xBB, 0xD3, 0xE1, 0x5B, 0x26, 0x1F, 0x2E, 0x11, 0xB3, 0xFF, + 0x60, 0x47, 0x8B, 0x99, 0x4E, 0x22, 0x91, 0x3F, 0x96, 0xD1, 0xE2, 0x3E, + 0xB2, 0x31, 0xE5, 0xBB, 0x1C, 0x5F, 0x8C, 0xF3, 0xB7, 0xCF, 0xED, 0xAA, + 0xFC, 0xC9, 0x95, 0xFB, 0xB1, 0xBF, 0x39, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xC6, 0xF8, 0x0B, 0xA0, 0xD0, 0xFF, 0x56, 0x56, 0xDB, 0x79, + 0x47, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, + 0x82, + }; + unsigned int Resources_Images_env_file_icon_png_len = sizeof(Resources_Images_env_file_icon_png); + // Data for file: Resources_Images_file_icon_png_path const std::string Resources_Images_file_icon_png_path = R"(Resources/Images/file_icon.png)"; unsigned char Resources_Images_file_icon_png[] = { diff --git a/Nuake/src/Resource/StaticResources.h b/Nuake/src/Resource/StaticResources.h index 54992e8a..ef86391f 100644 --- a/Nuake/src/Resource/StaticResources.h +++ b/Nuake/src/Resource/StaticResources.h @@ -89,6 +89,9 @@ namespace Nuake { extern const std::string Resources_Images_editor_icon_png_path; extern unsigned int Resources_Images_editor_icon_png_len; extern unsigned char Resources_Images_editor_icon_png[]; + extern const std::string Resources_Images_env_file_icon_png_path; + extern unsigned int Resources_Images_env_file_icon_png_len; + extern unsigned char Resources_Images_env_file_icon_png[]; extern const std::string Resources_Images_file_icon_png_path; extern unsigned int Resources_Images_file_icon_png_len; extern unsigned char Resources_Images_file_icon_png[]; diff --git a/Nuake/src/Scene/Components.h b/Nuake/src/Scene/Components.h index c714bf0c..90e8ee10 100644 --- a/Nuake/src/Scene/Components.h +++ b/Nuake/src/Scene/Components.h @@ -26,3 +26,4 @@ #include "Components/TransformComponent.h" #include "Components/UIComponent.h" #include "Components/SkyComponent.h" +#include "Components/EnvironmentComponent.h" diff --git a/Nuake/src/Scene/Components/EnvironmentComponent.cpp b/Nuake/src/Scene/Components/EnvironmentComponent.cpp new file mode 100644 index 00000000..21399bde --- /dev/null +++ b/Nuake/src/Scene/Components/EnvironmentComponent.cpp @@ -0,0 +1,19 @@ +#include "EnvironmentComponent.h" +#include "src/FileSystem/File.h" +#include "src/FileSystem/FileSystem.h" + +namespace Nuake +{ + json EnvironmentComponent::Serialize() + { + BEGIN_SERIALIZE(); + SERIALIZE_RES_FILE(EnvResourceFilePath); + END_SERIALIZE(); + } + + bool EnvironmentComponent::Deserialize(const json& j) + { + DESERIALIZE_RES_FILE(EnvResourceFilePath); + return true; + } +} \ No newline at end of file diff --git a/Nuake/src/Scene/Components/EnvironmentComponent.h b/Nuake/src/Scene/Components/EnvironmentComponent.h new file mode 100644 index 00000000..23b056c0 --- /dev/null +++ b/Nuake/src/Scene/Components/EnvironmentComponent.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Component.h" + +#include "src/Core/Core.h" +#include "src/Resource/Serializable.h" +#include "src/Resource/UUID.h" + +namespace Nuake +{ + class EnvironmentComponent : public Component + { + NUAKECOMPONENT(EnvironmentComponent, "Environment") + + static void InitializeComponentClass() + { + BindComponentField<&EnvironmentComponent::EnvResource>("EnvResource", "Environment Resource"); + SetFlags(ComponentFieldTrait::Internal, ComponentFieldTrait::Transient); + BindComponentField<&EnvironmentComponent::EnvResourceFilePath>("EnvResourceFilePath", "File Path"); + ResourceFileRestriction("_EnvFile"); + } + + public: + UUID EnvResource = UUID(0); + ResourceFile EnvResourceFilePath; + + json Serialize(); + bool Deserialize(const json& j); + }; +} diff --git a/Nuake/src/Scene/Entities/Entity.cpp b/Nuake/src/Scene/Entities/Entity.cpp index 017f603a..a818628c 100644 --- a/Nuake/src/Scene/Entities/Entity.cpp +++ b/Nuake/src/Scene/Entities/Entity.cpp @@ -91,6 +91,8 @@ namespace Nuake SERIALIZE_OBJECT_REF_LBL("PrefabMember", GetComponent()) if (HasComponent()) SERIALIZE_OBJECT_REF_LBL("SkyComponent", GetComponent()) + if (HasComponent()) + SERIALIZE_OBJECT_REF_LBL("EnvironmentComponent", GetComponent()) END_SERIALIZE(); } @@ -174,6 +176,7 @@ namespace Nuake DESERIALIZE_COMPONENT(NavMeshVolumeComponent); DESERIALIZE_COMPONENT(UIComponent); DESERIALIZE_COMPONENT(SkyComponent); + DESERIALIZE_COMPONENT(EnvironmentComponent); return false; } diff --git a/Nuake/src/Scene/Lighting/Environment.cpp b/Nuake/src/Scene/Lighting/Environment.cpp index 66752561..ccd2b3b5 100644 --- a/Nuake/src/Scene/Lighting/Environment.cpp +++ b/Nuake/src/Scene/Lighting/Environment.cpp @@ -4,11 +4,12 @@ #include "src/Core/Core.h" -namespace Nuake { - - Environment::Environment() +namespace Nuake +{ + Environment::Environment() : + m_AmbientColor(1.0f, 1.0f, 1.0f, 1.0f) { - m_AmbientColor = glm::vec4(1.0f, 1.0f, 1.0f, 1.0f); + ProceduralSkybox = CreateRef(); CurrentSkyType = SkyType::ProceduralSky; @@ -43,6 +44,11 @@ namespace Nuake { mSSR = CreateScope(); } + Environment::Environment(const std::string& path) : Environment() + { + this->Path = path; + } + glm::vec4 Environment::GetAmbientColor() { return m_AmbientColor; @@ -76,6 +82,7 @@ namespace Nuake { { BEGIN_SERIALIZE(); SERIALIZE_VAL(CurrentSkyType); + j["UUID"] = static_cast(ID); // Bloom SERIALIZE_VAL(BloomEnabled); diff --git a/Nuake/src/Scene/Lighting/Environment.h b/Nuake/src/Scene/Lighting/Environment.h index 664883d7..ea51c241 100644 --- a/Nuake/src/Scene/Lighting/Environment.h +++ b/Nuake/src/Scene/Lighting/Environment.h @@ -2,6 +2,7 @@ #include "src/Core/Maths.h" #include "src/Core/Core.h" #include "src/Scene/Environment/ProceduralSky.h" +#include "src/Resource/Resource.h" #include "src/Resource/Serializable.h" #include "src/Rendering/PostFX/Bloom.h" @@ -20,9 +21,10 @@ namespace Nuake // CubeMap }; - class Environment : public ISerializable + class Environment : public Resource, ISerializable { public: + Environment(const std::string& path); Environment(); SkyType CurrentSkyType; diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 4ee85253..9e3b25fb 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -6,6 +6,8 @@ #include "src/Core/OS.h" #include "src/Physics/PhysicsManager.h" +#include "src/Resource/ResourceManager.h" + #include "src/Scene/Systems/ScriptingSystem.h" #include "src/Scene/Systems/PhysicsSystem.h" #include "src/Scene/Systems/TransformSystem.h" @@ -32,6 +34,7 @@ #include "src/Scene/Components/SkinnedModelComponent.h" #include "src/Scene/Components/BoneComponent.h" + #include #include @@ -41,6 +44,8 @@ namespace Nuake { + Ref Scene::m_Environment = nullptr; + Ref Scene::New() { return CreateRef(); @@ -48,9 +53,13 @@ namespace Nuake Scene::Scene() { + if (m_Environment == nullptr) + { + m_Environment = CreateRef(); + } + m_Systems = std::vector>(); m_EditorCamera = CreateRef(); - m_Environement = CreateRef(); physicsSystem = CreateRef(this); scriptingSystem = CreateRef(this); @@ -583,14 +592,26 @@ namespace Nuake return m_EditorCamera; } - Ref Scene::GetEnvironment() const + Ref Scene::GetEnvironment() { - return m_Environement; - } + auto view = m_Registry.view(); + for (auto e : view) + { + auto& envComponent = view.get(e); + if (envComponent.EnvResourceFilePath.Exist() && envComponent.EnvResource == UUID(0)) + { + auto env = ResourceLoader::LoadEnvironment(envComponent.EnvResourceFilePath.GetRelativePath()); + envComponent.EnvResource = env->ID; + return env; + } - void Scene::SetEnvironment(Ref env) - { - m_Environement = env; + if (ResourceManager::IsResourceLoaded(envComponent.EnvResource)) + { + return ResourceManager::GetResource(envComponent.EnvResource); + } + } + + return m_Environment; } bool Scene::Save() @@ -647,7 +668,6 @@ namespace Nuake { BEGIN_SERIALIZE(); SERIALIZE_VAL(Name); - SERIALIZE_OBJECT(m_Environement) SERIALIZE_VAL(Path) std::vector entities = std::vector(); @@ -685,12 +705,6 @@ namespace Nuake Path = j["Path"]; } - m_Environement = CreateRef(); - if (j.contains("m_Environement")) - { - m_Environement->Deserialize(j["m_Environement"]); - } - // Parse entities if (!j.contains("Entities")) { diff --git a/Nuake/src/Scene/Scene.h b/Nuake/src/Scene/Scene.h index eec28b31..aa5a29a6 100644 --- a/Nuake/src/Scene/Scene.h +++ b/Nuake/src/Scene/Scene.h @@ -37,7 +37,7 @@ namespace Nuake // You can create a new system(see 'Systems/'.) and register it // In the scene constructor. std::vector> m_Systems; - Ref m_Environement; + static Ref m_Environment; public: Ref m_EditorCamera; @@ -88,8 +88,7 @@ namespace Nuake template static void CopyComponent(entt::registry& dst, entt::registry& src); - Ref GetEnvironment() const; - void SetEnvironment(Ref env); + Ref GetEnvironment(); bool Save(); bool SaveAs(const std::string& path); diff --git a/Nuake/src/UI/ImUI.h b/Nuake/src/UI/ImUI.h index 34f6ffcb..fb14a0c5 100644 --- a/Nuake/src/UI/ImUI.h +++ b/Nuake/src/UI/ImUI.h @@ -11,6 +11,19 @@ namespace Nuake { +#define BEGIN_COLLAPSE_HEADER(names) \ + UIFont* names##_boldFont = new UIFont(Fonts::Bold); \ + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f)); \ + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.f, 8.f)); \ + bool names##_Opened = ImGui::CollapsingHeader((std::string(" ") + #names).c_str()); \ + ImGui::PopStyleVar(); \ + delete names##_boldFont; \ + if (names##_Opened) { \ + +#define END_COLLAPSE_HEADER() \ +} \ + ImGui::PopStyleVar(); \ + namespace UI { static uint32_t PrimaryCol = IM_COL32(97, 0, 255, 255); diff --git a/Resources/Images/env_file_icon.png b/Resources/Images/env_file_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..feeb024811f82a4853a989dc590a47827a033179 GIT binary patch literal 985 zcmV;~119{5P)uR-nl@Uxki8=RK zFpLS@#*|xA9!+`CI(sa0bvBW0?%lbWpr7ppE@({&=#!hW?Pz=N*Oi$qe#kOGx;7s- zavYX?2UA{MDXm>eg1XP9?9H%r@3p;mZHsH;()|BPP-n+S9aIEVpIUNxyO-=E-q-f_8T2YEoNV(T#IQlnrJbV zjb)Q!?-4s!q5~Twb+|A^+)NGEW=Lf>xMBB ziEPJhliZc(>A;!WN%ML~uH#nYsv~anTC7LP?_=A<(qeC_wAEq_GBhbu&APtGxeEf4 zxMM?-@}{*!a6w$jxzpop=P@`QlaxsocHZ}-a_+ofJT&}o*N}u%i=l0+6RooKxc-@a zw)I(Nq}7K@F}th>Gdubz)3e{bmgXJhcQyC4cSr#KnDR^i?^egzCuE3?DRxM)L)^)( z8Rkxi|6pmz)p?jWDgU0y%gkoIhu9YqOkiyg{CkPdj_v#4SR%#B{@`xvT|vB$d~u=t z?wGo#&71Z{&2WNsL!VsT+NP&XZJX)6w`lra&ISIO59@7 zYP<3KJ@OzZXmuO>C3ffthMP8x53PdUv6u%`i(!KDW9aY^k&w1z*b5-{>U|Z|nZP`F zLF#?^peG@%k8`#9JiT`!akjKNboC~sBOzTqBlGJC+G+LmPCvLwOZ{6n^!O!fNk;fK zWUfqe+iCq>+dN3jeoO#euegipL2w$9v37w>gFxo)*rumFd+x^dpzx_9FUEDzp107o z{-U&BH`8Jwkb0%