diff --git a/Editor/resources/Fonts/OpenSans-Bold.ttf b/Editor/resources/Fonts/OpenSans-Bold.ttf new file mode 100644 index 00000000..b379424e Binary files /dev/null and b/Editor/resources/Fonts/OpenSans-Bold.ttf differ diff --git a/Editor/resources/Shaders/deferred.shader b/Editor/resources/Shaders/deferred.shader index 4e8d85c2..f3db8924 100644 --- a/Editor/resources/Shaders/deferred.shader +++ b/Editor/resources/Shaders/deferred.shader @@ -32,13 +32,6 @@ in mat4 InvView; uniform float u_Exposure; uniform vec3 u_EyePosition; -// Environmnent -uniform float u_FogAmount; -uniform float u_FogStepCount; -uniform samplerCube u_IrradianceMap; -uniform samplerCube u_PrefilterMap; -uniform sampler2D u_BrdfLUT; - // GBuffer uniform sampler2D m_Depth; uniform sampler2D m_Albedo; @@ -55,7 +48,6 @@ struct Light { vec3 Color; float Strength; vec3 Position; - mat4 LightTransform; int ShadowMapsIDs[4]; float CascadeDepth[4]; mat4 LightTransforms[4]; @@ -147,7 +139,7 @@ float ShadowCalculation(Light light, vec3 FragPos, vec3 normal) if (shadowmap == -1) return 1.0; - vec4 fragPosLightSpace = light.LightTransforms[0] * vec4(FragPos, 1.0f); + vec4 fragPosLightSpace = light.LightTransforms[shadowmap] * vec4(FragPos, 1.0f); // perform perspective divide vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; @@ -161,67 +153,10 @@ float ShadowCalculation(Light light, vec3 FragPos, vec3 normal) float shadow = 0.0; - float pcfDepth = texture(ShadowMaps[0], projCoords.xy).r; + float pcfDepth = texture(ShadowMaps[shadowmap], projCoords.xy).r; return currentDepth - bias > pcfDepth ? 1.0 : 0.0; } -// Mie scaterring approximated with Henyey-Greenstein phase function. -float ComputeScattering(float lightDotView) -{ - float result = 1.0f - u_FogAmount * u_FogAmount; - result /= (4.0f * PI * pow(1.0f + u_FogAmount * u_FogAmount - (2.0f * u_FogAmount) * lightDotView, 1.5f)); - return result; -} - - -vec3 ComputeVolumetric(vec3 FragPos, Light light) -{ - // world space frag position. - vec3 startPosition = u_EyePosition; // Camera Position - vec3 rayVector = FragPos - startPosition; // Ray Direction - - float rayLength = length(rayVector); // Length of the raymarched - - float stepLength = rayLength / u_FogStepCount; // Step length - vec3 rayDirection = rayVector / rayLength; - vec3 step = rayDirection * stepLength; // Normalized to step length direction - - vec3 currentPosition = startPosition; // First step position - vec3 accumFog = vec3(0.0f, 0.0f, 0.0f); // accumulative color - - // Raymarching - for (int i = 0; i < u_FogStepCount; i++) - { - vec4 fragPosLightSpace = light.LightTransforms[0] * vec4(currentPosition, 1.0f); - // perform perspective divide - vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; - // transform to [0,1] range - projCoords = projCoords * 0.5 + 0.5; - - float currentDepth = projCoords.z; - - // get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) - vec2 texelSize = 1.0 / textureSize(ShadowMaps[0], 0); - - float closestDepth = texture(ShadowMaps[0], projCoords.xy).r; - - if (closestDepth > currentDepth) - accumFog += (ComputeScattering(dot(rayDirection, light.Direction)).xxx * light.Color); - - //float ditherPattern[4][4] = { - // { 0.0f, 0.5f, 0.125f, 0.625f}, - // { 0.75f, 0.22f, 0.875f, 0.375f}, - // { 0.1875f, 0.6875f, 0.0625f, 0.5625}, - // { 0.9375f, 0.4375f, 0.8125f, 0.3125} - //}; - - currentPosition += step; //* ditherPattern[int(gl_FragCoord.x) % 4][int(gl_FragCoord.y) % 4]; - } - accumFog /= u_FogStepCount; - - return accumFog; -} - void main() { vec3 worldPos = WorldPosFromDepth(texture(m_Depth, UV).r); @@ -246,12 +181,11 @@ void main() F0 = mix(F0, albedo, metallic); // reflectance equation + vec3 eyeDirection = normalize(u_EyePosition - worldPos); + vec3 Lo = vec3(0.0); vec3 fog = vec3(0.0); float shadow = 0.0f; - - vec3 eyeDirection = normalize(u_EyePosition - worldPos); - for (int i = 0; i < LightCount; i++) { vec3 L = normalize(Lights[i].Position - worldPos); @@ -262,10 +196,6 @@ void main() if (Lights[i].Type == 0) { L = normalize(Lights[i].Direction); attenuation = 1.0f; - - if (Lights[i].Volumetric == 1) - fog += ComputeVolumetric(worldPos, Lights[i]); - shadow += ShadowCalculation(Lights[i], worldPos, N); } @@ -304,14 +234,6 @@ void main() vec3 ambient = (kD * albedo) * ao; vec3 color = ambient + Lo; - color += fog; - //color = color / (color + vec3(1.0)); - //const float gamma = 2.2; - //// HDR tonemapping - //color = vec3(1.0) - exp(-color * 1.0); - //// gamma correct - //color = pow(color, vec3(1.0 / gamma)); - - FragColor = mix(vec4(color, 1.0), vec4(albedo, 1.0), 0); + FragColor = vec4(color, 1.0); } \ No newline at end of file diff --git a/Editor/resources/Shaders/volumetric.shader b/Editor/resources/Shaders/volumetric.shader new file mode 100644 index 00000000..6d6fde46 --- /dev/null +++ b/Editor/resources/Shaders/volumetric.shader @@ -0,0 +1,120 @@ +#shader vertex +#version 460 core + +layout(location = 0) in vec3 VertexPosition; +layout(location = 1) in vec2 UVPosition; + +out flat vec2 UV; +out mat4 InvView; +out mat4 InvProjection; + +uniform mat4 u_View; +uniform mat4 u_Projection; + +void main() +{ + UV = UVPosition; + InvView = inverse(u_View); + InvProjection = inverse(u_Projection); + gl_Position = vec4(VertexPosition, 1.0f); +} + +#shader fragment +#version 460 core + +in mat4 InvView; +in mat4 InvProjection; + +uniform sampler2D u_Depth; + +uniform vec3 u_CamPosition; +uniform int u_StepCount; +uniform float u_FogAmount; + +const int MAX_LIGHT = 25; +uniform int u_LightCount; +struct Light { + mat4 transform; + vec3 color; + vec3 direction; + sampler2D shadowmap; +}; + +uniform Light u_Lights[MAX_LIGHT]; + +in vec2 UV; + +out vec4 FragColor; +const float PI = 3.141592653589793f; + +// Mie scaterring approximated with Henyey-Greenstein phase function. +float ComputeScattering(float lightDotView) +{ + float result = 1.0f - u_FogAmount * u_FogAmount; + result /= (4.0f * PI * pow(1.0f + u_FogAmount * u_FogAmount - (2.0f * u_FogAmount) * lightDotView, 1.5f)); + return result; +} + +vec3 ComputeVolumetric(vec3 FragPos, Light light) +{ + vec3 rayVector = FragPos - u_CamPosition; // Ray Direction + + float rayLength = length(rayVector); // Length of the raymarched + + float stepLength = rayLength / u_StepCount; // Step length + vec3 rayDirection = rayVector / rayLength; + vec3 step = rayDirection * stepLength; // Normalized to step length direction + + vec3 accumFog = vec3(0.0f, 0.0f, 0.0f); // accumulative color + + // Raymarching + vec3 currentPosition = u_CamPosition; + for (int i = 0; i < u_StepCount; i++) + { + vec4 fragPosLightSpace = light.transform * vec4(currentPosition, 1.0f); + // perform perspective divide + vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w; + // transform to [0,1] range + projCoords = projCoords * 0.5 + 0.5; + + float currentDepth = projCoords.z; + float closestDepth = texture(light.shadowmap, projCoords.xy).r; + if (closestDepth > currentDepth) + accumFog += (ComputeScattering(dot(rayDirection, normalize(light.direction))).xxx * light.color); + + currentPosition += step; //* ditherPattern[int(gl_FragCoord.x) % 4][int(gl_FragCoord.y) % 4]; + } + accumFog /= u_StepCount; + + return accumFog; +} + +// Converts depth to World space coords. +vec3 WorldPosFromDepth(float depth) { + float z = depth * 2.0 - 1.0; + + vec4 clipSpacePosition = vec4(UV * 2.0 - 1.0, z, 1.0); + vec4 viewSpacePosition = InvProjection * clipSpacePosition; + + // Perspective division + viewSpacePosition /= viewSpacePosition.w; + + vec4 worldSpacePosition = InvView * viewSpacePosition; + + return worldSpacePosition.xyz; +} + +void main() +{ + float depth = texture(u_Depth, UV).r; + vec3 globalFragmentPosition = WorldPosFromDepth(depth); + + vec3 fog = vec3(0, 0, 0); + + for (int i = 0; i < u_LightCount; i++) + { + fog += ComputeVolumetric(globalFragmentPosition, u_Lights[i]); + } + + FragColor = vec4(mix(fog, vec3(depth), 0.01), 1.0); +} \ No newline at end of file diff --git a/Editor/src/EditorInterface.cpp b/Editor/src/EditorInterface.cpp index 3c70b705..27c02cfd 100644 --- a/Editor/src/EditorInterface.cpp +++ b/Editor/src/EditorInterface.cpp @@ -40,6 +40,7 @@ namespace Nuake { Ref userInterface; ImFont* normalFont; + ImFont* boldFont; ImFont* EditorInterface::bigIconFont; void EditorInterface::Init() { @@ -63,6 +64,8 @@ namespace Nuake { std::string name = ICON_FA_GAMEPAD + std::string(" Scene"); if (ImGui::Begin(name.c_str())) { + + ImGui::PopStyleVar(); Overlay(); ImGuizmo::BeginFrame(); @@ -146,68 +149,6 @@ namespace Nuake { ImGui::PopStyleVar(); } ImGui::End(); - - if (m_IsEntitySelected) - { - //if (ImGui::Begin("DEFERRED")) - //{ - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = Engine::GetCurrentWindow()->GetDeferredBuffer()->GetTexture(GL_COLOR_ATTACHMENT0); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // - //} - //ImGui::End(); - // - //if (ImGui::Begin("GBUFFER")) - //{ - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_DEPTH_ATTACHMENT); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // - //} - //ImGui::End(); - //if (ImGui::Begin("GBUFFER2")) - //{ - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT0); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // - //} - //ImGui::End(); - //if (ImGui::Begin("GBUFFER3")) - //{ - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT1); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // - //} - //ImGui::End(); - //if (ImGui::Begin("GBUFFER4")) - //{ - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = Engine::GetCurrentWindow()->GetGBuffer()->GetTexture(GL_COLOR_ATTACHMENT2); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // - //} - //ImGui::End(); - // - //if (ImGui::Begin("CSM 2")) - //{ - // if (m_SelectedEntity.HasComponent()) - // { - // ImVec2 regionAvail = ImGui::GetContentRegionAvail(); - // glm::vec2 viewportPanelSize = glm::vec2(regionAvail.x, regionAvail.y); - // Ref texture = m_SelectedEntity.GetComponent().m_Framebuffers[1]->GetTexture(GL_DEPTH_ATTACHMENT); - // ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); - // } - //} - //ImGui::End(); - } } static int selected = 0; @@ -223,9 +164,13 @@ namespace Nuake { if (m_SelectedEntity == e) base_flags |= ImGuiTreeNodeFlags_Selected; + ImGui::TableNextColumn(); + + + ImGui::TableNextColumn(); + // Write in normal font. ImGui::PushFont(normalFont); - // If has no childrens draw tree node leaf if (parent.Children.size() <= 0) base_flags |= ImGuiTreeNodeFlags_Leaf; @@ -278,45 +223,49 @@ namespace Nuake { m_IsEntitySelected = true; } - if (ImGui::BeginPopupContextItem()) + if (m_IsEntitySelected) { - if (m_SelectedEntity.HasComponent()) + if (ImGui::BeginPopupContextItem()) { - if (ImGui::Selectable("Focus camera")) + if (m_SelectedEntity.HasComponent()) { - Engine::GetCurrentScene()->m_EditorCamera->Translation = m_SelectedEntity.GetComponent().Translation; - Engine::GetCurrentScene()->m_EditorCamera->SetDirection(m_SelectedEntity.GetComponent().CameraInstance->GetDirection()); + if (ImGui::Selectable("Focus camera")) + { + Engine::GetCurrentScene()->m_EditorCamera->Translation = m_SelectedEntity.GetComponent().Translation; + Engine::GetCurrentScene()->m_EditorCamera->SetDirection(m_SelectedEntity.GetComponent().CameraInstance->GetDirection()); + } + ImGui::Separator(); } - ImGui::Separator(); - } - if (ImGui::Selectable("Remove")) - { - QueueDeletion = e; - } - - - if (ImGui::Selectable("Move to root")) - { - auto& p = m_SelectedEntity.GetComponent(); - if (p.HasParent) + if (ImGui::Selectable("Remove")) { - auto& pp = p.Parent.GetComponent(); - pp.RemoveChildren(m_SelectedEntity); - p.HasParent = false; + QueueDeletion = e; } + + + if (ImGui::Selectable("Move to root")) + { + auto& p = m_SelectedEntity.GetComponent(); + if (p.HasParent) + { + auto& pp = p.Parent.GetComponent(); + pp.RemoveChildren(m_SelectedEntity); + p.HasParent = false; + } + } + if (ImGui::Selectable("Save as new prefab")) + { + Ref newPrefab = Prefab::CreatePrefabFromEntity(m_SelectedEntity); + std::string savePath = FileDialog::SaveFile("*.prefab"); + newPrefab->SaveAs(savePath); + m_SelectedEntity.AddComponent().PrefabInstance = newPrefab; + } + ImGui::EndPopup(); } - if (ImGui::Selectable("Save as new prefab")) - { - Ref newPrefab = Prefab::CreatePrefabFromEntity(m_SelectedEntity); - std::string savePath = FileDialog::SaveFile("*.prefab"); - newPrefab->SaveAs(savePath); - m_SelectedEntity.AddComponent().PrefabInstance = newPrefab; - } - ImGui::EndPopup(); } if (open) { + // Caching list to prevent deletion while iterating. std::vector childrens = parent.Children; for (auto c : childrens) @@ -324,12 +273,10 @@ namespace Nuake { ImGui::TreePop(); } + ImGui::PopFont(); } - - - void EditorInterface::DrawSceneTree() { Ref scene = Engine::GetCurrentScene(); @@ -375,64 +322,78 @@ namespace Nuake { ImGui::End(); std::string title = ICON_FA_TREE + std::string(" Hierarchy"); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); if (ImGui::Begin(title.c_str())) { // Buttons to add and remove entity. - if(ImGui::BeginChild("Buttons", ImVec2(300, 20), false)) + if(ImGui::BeginChild("Buttons", ImVec2(300, 30), false)) { // Add entity. - if (ImGui::Button("Add")) + if (ImGui::Button(ICON_FA_PLUS)) Engine::GetCurrentScene()->CreateEntity("Entity"); - ImGui::SameLine(); - - // Remove Entity - if (ImGui::Button("Remove")) - { - scene->DestroyEntity(m_SelectedEntity); - - // Unselect delted entity. - m_SelectedEntity = scene->GetAllEntities().at(0); - } + //// Remove Entity + //if (ImGui::Button("Remove")) + //{ + // scene->DestroyEntity(m_SelectedEntity); + // + // // Unselect delted entity. + // m_SelectedEntity = scene->GetAllEntities().at(0); + //} } ImGui::EndChild(); ImGui::Separator(); // Draw a tree of entities. - if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), true)) + ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(26.f / 255.0f, 26.f / 255.0f, 26.f / 255.0f, 1)); + if (ImGui::BeginChild("Scene tree", ImGui::GetContentRegionAvail(), false)) { - std::vector entities = scene->GetAllEntities(); - for (Entity e : entities) + if (ImGui::BeginTable("entity_table", 2, ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoBordersInBody)) { - ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; + std::string icon = ICON_FA_EYE; + ImGui::TableSetupColumn((" " + icon).c_str(), ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentDisable | ImGuiTableColumnFlags_WidthFixed, 16); + ImGui::TableSetupColumn("Label", ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_IndentEnable); + ImGui::TableHeadersRow(); + ImGui::TableNextRow(); + + std::vector entities = scene->GetAllEntities(); + for (Entity e : entities) + { + ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; std::string name = e.GetComponent().Name; // If selected add selected flag. if (m_SelectedEntity == e) base_flags |= ImGuiTreeNodeFlags_Selected; // Write in normal font. - ImGui::PushFont(normalFont); + ImGui::PushFont(normalFont); - // Small icons + name. - std::string label = ICON_FA_CIRCLE + std::string(" ") + name; + // Small icons + name. + std::string label = ICON_FA_CIRCLE + std::string(" ") + name; - // Draw all entity without parents. - if (!e.GetComponent().HasParent) - { - // Recursively draw childrens. - DrawEntityTree(e); + // Draw all entity without parents. + if (!e.GetComponent().HasParent) + { + // Recursively draw childrens. + DrawEntityTree(e); + } + + // Pop font. + ImGui::PopFont(); + + // Right click menu + //if (ImGui::BeginPopupContextItem()) + // ImGui::EndPopup(); } - - // Pop font. - ImGui::PopFont(); - - // Right click menu - //if (ImGui::BeginPopupContextItem()) - // ImGui::EndPopup(); } + + + + ImGui::EndTable(); } ImGui::EndChild(); + ImGui::PopStyleColor(); if (ImGui::BeginDragDropTarget()) // Drag n drop new prefab file into scene tree { @@ -461,6 +422,7 @@ namespace Nuake { } } ImGui::End(); + ImGui::PopStyleVar(); } @@ -542,23 +504,84 @@ namespace Nuake { ImGui::Separator(); } - ImGui::PushFont(normalFont); + std::string iconTransform = ICON_FA_MAP_MARKER; - if (ImGui::CollapsingHeader((iconTransform + " Transform").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) + + ImGui::PushFont(boldFont); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 8)); + bool headerOpened = ImGui::CollapsingHeader(" TRANSFORM", ImGuiTreeNodeFlags_DefaultOpen); + if (headerOpened) { - ImGui::TextColored(ImGui::GetStyleColorVec4(1), "Transform properties"); + ImGui::PopFont(); + ImGui::PopStyleVar(); + if (ImGui::BeginTable("TransformTable", 3, ImGuiTableFlags_BordersInner)) + { + TransformComponent& component = m_SelectedEntity.GetComponent(); + + ImGui::TableSetupColumn("name", 0, 0.3); + ImGui::TableSetupColumn("set", 0, 0.6); + ImGui::TableSetupColumn("reset", 0, 0.1); + + ImGui::TableNextColumn(); + ImGui::Text("Translation"); + ImGui::TableNextColumn(); + ImGuiHelper::DrawVec3("Translation", &component.Translation); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetTranslation = ICON_FA_UNDO + std::string("##ResetTranslation"); + if (ImGui::Button(resetTranslation.c_str())) component.Translation = Vector3(0, 0, 0); + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Rotation"); + + ImGui::TableNextColumn(); + ImGuiHelper::DrawVec3("Rotation", &component.Rotation); + + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetRotation = ICON_FA_UNDO + std::string("##ResetRotation"); + if (ImGui::Button(resetRotation.c_str())) component.Rotation = Vector3(0, 0, 0); + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Scale"); + + ImGui::TableNextColumn(); + ImGuiHelper::DrawVec3("Scale", &component.Scale); + + ImGui::TableNextColumn(); + std::string resetScale = ICON_FA_UNDO + std::string("##ResetScale"); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + if (ImGui::Button(resetScale.c_str())) component.Scale = Vector3(1, 1, 1); + ImGui::PopStyleColor(); + + ImGui::EndTable(); + } //ImGui::InputText("Name:", selectedEntity->m_Name.data(), 12); - TransformComponent& component = m_SelectedEntity.GetComponent(); - ImGuiHelper::DrawVec3("Translation", &component.Translation); - ImGuiHelper::DrawVec3("Rotation", &component.Rotation); - ImGuiHelper::DrawVec3("Scale", &component.Scale); - ImGui::Separator(); + } + else + { + ImGui::PopStyleVar(); + ImGui::PopFont(); + } + + ImGui::PopStyleVar(); if (m_SelectedEntity.HasComponent()) { - if (ImGui::CollapsingHeader("Interface", ImGuiTreeNodeFlags_DefaultOpen)) + ImGui::PushFont(boldFont); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 8)); + + headerOpened = ImGui::CollapsingHeader("Interface", ImGuiTreeNodeFlags_DefaultOpen); + if (headerOpened) { + ImGui::PopFont(); + ImGui::PopStyleVar(); InterfaceComponent& component = m_SelectedEntity.GetComponent(); std::string& path = component.Path; char pathBuffer[256]; @@ -583,7 +606,16 @@ namespace Nuake { ImGui::EndDragDropTarget(); } } + else + { + ImGui::PopStyleVar(); + ImGui::PopFont(); + } + + + ImGui::PopStyleVar(); } + if (m_SelectedEntity.HasComponent()) { @@ -674,14 +706,137 @@ namespace Nuake { } - if (m_SelectedEntity.HasComponent()) { - std::string icon = ICON_FA_LIGHTBULB; - if (ImGui::CollapsingHeader((icon + " " + "Light").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) - { - m_SelectedEntity.GetComponent().DrawEditor(); - ImGui::Separator(); - } + if (m_SelectedEntity.HasComponent()) + { + ImGui::PushFont(boldFont); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 8)); + bool headerOpened = ImGui::CollapsingHeader(" LIGHT", ImGuiTreeNodeFlags_DefaultOpen); + if (headerOpened) + { + ImGui::PopFont(); + ImGui::PopStyleVar(); + if (ImGui::BeginTable("TransformTable", 3, ImGuiTableFlags_BordersInner)) + { + LightComponent& component = m_SelectedEntity.GetComponent(); + + ImGui::TableSetupColumn("name", 0, 0.3); + ImGui::TableSetupColumn("set", 0, 0.6); + ImGui::TableSetupColumn("reset", 0, 0.1); + + ImGui::TableNextColumn(); + ImGui::Text("Color"); + ImGui::TableNextColumn(); + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()); + ImGui::ColorEdit3("##lightcolor", &component.Color.r, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel); + ImGui::PopItemWidth(); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetColor = ICON_FA_UNDO + std::string("##ResetTranslation"); + if (ImGui::Button(resetColor.c_str())) component.Color = Vector3(1, 1, 1); + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Strength"); + + ImGui::TableNextColumn(); + ImGui::SliderFloat("Strength", &component.Strength, 0.0f, 100.0f); + + ImGui::TableNextColumn(); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetStrength = ICON_FA_UNDO + std::string("##resetStrength"); + if (ImGui::Button(resetStrength.c_str())) component.Strength = 10.0f; + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Cast Shadows"); + + ImGui::TableNextColumn(); + ImGui::Checkbox("##CastShadows", &component.CastShadows); + + ImGui::TableNextColumn(); + std::string resetShadow = ICON_FA_UNDO + std::string("##resetShadow"); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + if (ImGui::Button(resetShadow.c_str())) component.CastShadows = false; + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Type"); + ImGui::TableNextColumn(); + const char* types[] = { "Directional", "Point", "Spot" }; + static const char* current_item = types[component.Type]; + + if (ImGui::BeginCombo("Type", current_item)) // The second parameter is the label previewed before opening the combo. + { + for (int n = 0; n < IM_ARRAYSIZE(types); n++) + { + bool is_selected = (current_item == types[n]); // You can store your selection however you want, outside or inside your objects + if (ImGui::Selectable(types[n], is_selected)) + { + current_item = types[n]; + component.Type = (LightType)n; + } + if (is_selected) + ImGui::SetItemDefaultFocus(); // You may set the initial focus when opening the combo (scrolling + for keyboard navigation support) + } + ImGui::EndCombo(); + } + + ImGui::TableNextColumn(); + std::string resetType = ICON_FA_UNDO + std::string("##resetType"); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + if (ImGui::Button(resetShadow.c_str())) component.Type = Point; + ImGui::PopStyleColor(); + + + if (component.Type == Directional) + { + ImGui::TableNextColumn(); + ImGui::Text("Is Volumetric"); + + ImGui::TableNextColumn(); + ImGui::Checkbox("##Volumetric", &component.IsVolumetric); + + ImGui::TableNextColumn(); + std::string resetIsVolumetric = ICON_FA_UNDO + std::string("##IsVolumetric"); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + if (ImGui::Button(resetIsVolumetric.c_str())) component.IsVolumetric = false; + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Sync Sky Direction"); + + ImGui::TableNextColumn(); + ImGui::Checkbox("##SyncSky", &component.SyncDirectionWithSky); + + ImGui::TableNextColumn(); + std::string resetSyncDirectionWithSky = ICON_FA_UNDO + std::string("##resetSyncDirectionWithSky"); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + if (ImGui::Button(resetSyncDirectionWithSky.c_str())) component.SyncDirectionWithSky = false; + ImGui::PopStyleColor(); + + ImGui::TableNextColumn(); + ImGui::Text("Direction"); + ImGui::TableNextColumn(); + ImGuiHelper::DrawVec3("Direction", &component.Direction); + ImGui::TableNextColumn(); + + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0)); + std::string resetDirection = ICON_FA_UNDO + std::string("##resetDirection"); + if (ImGui::Button(resetDirection.c_str())) component.Direction = Vector3(0, -1, 0); + ImGui::PopStyleColor(); + } + ImGui::EndTable(); + } + } + else + { + ImGui::PopStyleVar(); + ImGui::PopFont(); + } + ImGui::PopStyleVar(); } if (m_SelectedEntity.HasComponent()) { @@ -841,7 +996,6 @@ namespace Nuake { } } - ImGui::PopFont(); } ImGui::End(); } @@ -1078,9 +1232,9 @@ namespace Nuake { { // FIXME-VIEWPORT: Select a default viewport const float DISTANCE = 10.0f; - static int corner = 3; + int corner = 0; ImGuiIO& io = ImGui::GetIO(); - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; if (corner != -1) { window_flags |= ImGuiWindowFlags_NoMove; @@ -1093,24 +1247,42 @@ namespace Nuake { ImGui::SetNextWindowViewport(viewport->ID); } ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background + ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 32.0f); if (ImGui::Begin("Example: Simple overlay", &m_ShowOverlay, window_flags)) { - ImGui::Text("Developpement build 0.1"); - ImGui::Separator(); - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - if (ImGui::BeginPopupContextWindow()) - { - if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1; - if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0; - if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1; - if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2; - if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3; - if (m_ShowOverlay && ImGui::MenuItem("Close")) m_ShowOverlay = false; - ImGui::EndPopup(); - } - + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 100); + if (ImGui::Button(ICON_FA_HAND_POINTER)) CurrentOperation = ImGuizmo::OPERATION::TRANSLATE; + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_ARROWS_ALT)) CurrentOperation = ImGuizmo::OPERATION::TRANSLATE; + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_SYNC_ALT)) CurrentOperation = ImGuizmo::OPERATION::ROTATE; + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_EXPAND_ALT)) CurrentOperation = ImGuizmo::OPERATION::SCALE; + ImGui::PopStyleVar(); } + ImGui::PopStyleVar(); + ImGui::End(); + int corner2 = 1; + + window_flags |= ImGuiWindowFlags_NoMove; + ImGuiViewport* viewport = ImGui::GetWindowViewport(); + ImVec2 work_area_pos = ImGui::GetCurrentWindow()->Pos; // Instead of using viewport->Pos we use GetWorkPos() to avoid menu bars, if any! + ImVec2 work_area_size = ImGui::GetCurrentWindow()->Size; + ImVec2 window_pos = ImVec2((corner2 & 1) ? (work_area_pos.x + work_area_size.x - DISTANCE) : (work_area_pos.x + DISTANCE), (corner2 & 2) ? (work_area_pos.y + work_area_size.y - DISTANCE) : (work_area_pos.y + DISTANCE)); + ImVec2 window_pos_pivot = ImVec2((corner2 & 1) ? 1.0f : 0.0f, (corner2 & 2) ? 1.0f : 0.0f); + ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); + ImGui::SetNextWindowViewport(viewport->ID); + ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background + ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 32.0f); + if (ImGui::Begin("Controls", &m_ShowOverlay, window_flags)) + { + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 100); + if (ImGui::Button("...")) {}; + ImGui::PopStyleVar(); + } + + ImGui::PopStyleVar(); ImGui::End(); } @@ -1642,7 +1814,7 @@ namespace Nuake { static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; normalFont = io.Fonts->AddFontFromFileTTF("resources/Fonts/fa-solid-900.ttf", 11.0f, &icons_config, icons_ranges); - + boldFont = io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Bold.ttf", 16.0); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.5f, 0.5f)); ImGui::GetIO().Fonts->AddFontDefault(); icons_config.MergeMode = true; diff --git a/Nuake/src/Core/Logger.cpp b/Nuake/src/Core/Logger.cpp index fb8e7fee..bbb6870d 100644 --- a/Nuake/src/Core/Logger.cpp +++ b/Nuake/src/Core/Logger.cpp @@ -12,7 +12,7 @@ namespace Nuake { char buff[100]; time_t now = time(0); - strftime(buff, 100, "%Y-%m-%d %H:%M:%S.000", localtime(&now)); + strftime(buff, 100, "%H:%M:%S", localtime(&now)); LogEntry newLog = { type, @@ -20,8 +20,8 @@ namespace Nuake log }; - std::string msg = "[" + std::string(buff) + "]" + std::string(" - ") + log; - printf((msg + "\n").c_str()); + std::string msg = "[" + std::string(buff) + "]" + std::string(" - ") + log + "\n"; + printf((msg).c_str()); if (m_Logs.size() >= MAX_LOG) m_Logs.erase(m_Logs.begin()); diff --git a/Nuake/src/Rendering/Camera.cpp b/Nuake/src/Rendering/Camera.cpp index 45c8b3e3..340c570e 100644 --- a/Nuake/src/Rendering/Camera.cpp +++ b/Nuake/src/Rendering/Camera.cpp @@ -14,11 +14,10 @@ namespace Nuake { m_Type = PERSPECTIVE; Translation = position; - cameraDirection = glm::vec3(0, 0, 1); - up = glm::vec3(0.0f, 1.0f, 0.0f); - cameraRight = glm::normalize(glm::cross(up, cameraDirection)); - cameraUp = glm::cross(cameraDirection, cameraRight); - cameraFront = cameraDirection; + + Direction = Vector3(0, 0, 1); + Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction)); + Up = glm::cross(Direction, Right); m_Frustum = Frustum(GetTransform()); } @@ -27,10 +26,9 @@ namespace Nuake { m_Type = PERSPECTIVE; Translation = glm::vec3(0, 0, 0); - cameraDirection = glm::vec3(0, 0, 1); - up = glm::vec3(0.0f, 1.0f, 0.0f); - cameraRight = glm::normalize(glm::cross(up, cameraDirection)); - cameraUp = glm::cross(cameraDirection, cameraRight); + Direction = Vector3(0, 0, 1); + Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction)); + Up = glm::cross(Direction, Right); } void Camera::SetType(CAMERA_TYPE type) @@ -52,9 +50,8 @@ namespace Nuake //cam->cameraDirection.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch)); //cam->cameraFront = glm::normalize(cam->cameraDirection); //cam->cameraRight = glm::normalize(glm::cross(cam->up, cam->cameraFront)); - cameraDirection = glm::normalize(direction); - cameraFront = cameraDirection; - cameraRight = glm::normalize(glm::cross(up, cameraFront)); + Direction = glm::normalize(direction); + Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction)); } Vector3 Camera::GetTranslation() { @@ -62,7 +59,7 @@ namespace Nuake } Vector3 Camera::GetDirection() { - return cameraDirection; + return Direction; } Matrix4 Camera::GetPerspective() @@ -74,13 +71,13 @@ namespace Nuake Matrix4 Camera::GetTransform() { - glm::mat4 tr = lookAt(Translation, Translation + cameraFront, cameraUp); + glm::mat4 tr = lookAt(Translation, Translation + Direction, Up); return tr; } Matrix4 Camera::GetTransformRotation() { - return lookAt(glm::vec3(), cameraFront, cameraUp); + return lookAt(glm::vec3(), Direction, Up); } bool Camera::BoxFrustumCheck(const AABB& aabb) diff --git a/Nuake/src/Rendering/Camera.h b/Nuake/src/Rendering/Camera.h index 3251e606..e94144af 100644 --- a/Nuake/src/Rendering/Camera.h +++ b/Nuake/src/Rendering/Camera.h @@ -23,20 +23,16 @@ namespace Nuake Vector3 Rotation = { 0.0f, 0.0f, 0.0f }; Vector3 Scale = { 1.0f, 1.0f, 1.0f }; + Vector3 Up = Vector3(0, 1, 0); + Vector3 Right = Vector3(1, 0, 0); Matrix4 m_Perspective; + public: float AspectRatio = 16.0f / 9.0f; - // TODO: remove duplicate direction and have a proper api. - Vector3 up = Vector3(0.0f, 1.0f, 0.0f); - Vector3 cameraFront = Vector3(0.0f, 0.0f, 1.0f); - - Vector3 cameraTarget; - Vector3 cameraDirection; - + + Vector3 Direction = Vector3(0, 0, 1); Vector3 Translation = { 0.0f, 0.0f, 0.0f }; - Vector3 cameraRight; - Vector3 cameraUp; float Fov = 88.0f; float Exposure = 1.0f; float Speed = 1.0f; @@ -54,7 +50,7 @@ namespace Nuake Matrix4 GetPerspective(); Matrix4 GetTransform(); Matrix4 GetTransformRotation(); - + inline Vector3 GetRight() const { return Right; } bool BoxFrustumCheck(const AABB& aabb); json Serialize() override; diff --git a/Nuake/src/Rendering/PostFX/Bloom.cpp b/Nuake/src/Rendering/PostFX/Bloom.cpp index 9b87ce39..9030286a 100644 --- a/Nuake/src/Rendering/PostFX/Bloom.cpp +++ b/Nuake/src/Rendering/PostFX/Bloom.cpp @@ -102,14 +102,6 @@ namespace Nuake m_DownSampleFB[i]->Unbind(); } - if (ImGui::Begin("Downsample")) - { - ImGui::DragInt("MIP", &downsampleMip, 1.0f, 0, m_Iteration - 1); - ImGui::Image((void*)m_DownSampleFB[downsampleMip]->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); - } - ImGui::End(); - - for (int i = 0; i < m_Iteration; i++) { // Horizontal blur @@ -165,14 +157,6 @@ namespace Nuake Renderer::DrawQuad(Matrix4()); m_UpSampleFB[i]->Unbind(); } - - if (ImGui::Begin("UpSample")) - { - ImGui::DragInt("MIP", &upSampleMip, 1.0f, 0, m_Iteration - 1); - ImGui::Image((void*)m_UpSampleFB[upSampleMip]->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); - } - ImGui::End(); - m_FinalFB->Bind(); m_FinalFB->Clear(); { @@ -186,11 +170,6 @@ namespace Nuake } m_FinalFB->Unbind(); - if (ImGui::Begin("Final")) - { - ImGui::Image((void*)m_FinalFB->GetTexture()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0)); - } - ImGui::End(); } void Bloom::Resize(Vector2 size) diff --git a/Nuake/src/Rendering/PostFX/Bloom.h b/Nuake/src/Rendering/PostFX/Bloom.h index cedfbc79..bb53493e 100644 --- a/Nuake/src/Rendering/PostFX/Bloom.h +++ b/Nuake/src/Rendering/PostFX/Bloom.h @@ -18,7 +18,7 @@ namespace Nuake { const unsigned int MIN_ITERATION = 1; private: - float m_Threshold = 0.3f; + float m_Threshold = 2.3f; float m_BlurAmount = 12.0f; unsigned int m_Iteration; Vector2 m_Size; diff --git a/Nuake/src/Rendering/PostFX/Volumetric.cpp b/Nuake/src/Rendering/PostFX/Volumetric.cpp new file mode 100644 index 00000000..9d099aed --- /dev/null +++ b/Nuake/src/Rendering/PostFX/Volumetric.cpp @@ -0,0 +1,66 @@ +#include "Volumetric.h" +#include "src/Rendering/Shaders/ShaderManager.h" +#include "src/Rendering/Renderer.h" +#include +#include +namespace Nuake { + Volumetric::Volumetric() + { + mSize = Vector2(1920, 1080); + Init(); + } + + void Volumetric::SetDepth(Texture* depth) + { + Resize(depth->GetSize()); + mDepth = depth; + } + + void Volumetric::Init() + { + mFinalFramebuffer = CreateScope(false, mSize); + mFinalFramebuffer->SetTexture(CreateRef(mSize, GL_RGBA, GL_RGBA16F, GL_FLOAT)); + } + + void Volumetric::Resize(Vector2 size) + { + if (mSize == size) + return; + + mSize = size * mRenderRatio; + Init(); + } + + void Volumetric::Draw(Matrix4 projection, Matrix4 view, std::vector& lights) + { + mFinalFramebuffer->Bind(); + mFinalFramebuffer->Clear(); + RenderCommand::Disable(RendererEnum::DEPTH_TEST); + RenderCommand::Disable(RendererEnum::FACE_CULL); + + Shader* volumetricShader = ShaderManager::GetShader("resources/Shaders/volumetric.shader"); + volumetricShader->Bind(); + volumetricShader->SetUniformMat4f("u_Projection", projection); + volumetricShader->SetUniformMat4f("u_View", view); + volumetricShader->SetUniformTex("u_Depth", mDepth, 0); + volumetricShader->SetUniformVec3("u_CamPosition", view[3]); + volumetricShader->SetUniform1i("u_StepCount", mStepCount); + volumetricShader->SetUniform1f("u_FogAmount", mFogAmount); + volumetricShader->SetUniform1i("u_LightCount", lights.size()); + + for (uint16_t i = 0; i < lights.size(); i++) + { + LightComponent& light = lights[i]; + + std::string u_light = "u_Lights[" + std::to_string(i) + "]."; + volumetricShader->SetUniformMat4f(u_light + "transform", light.mViewProjections[0]); + volumetricShader->SetUniformVec3(u_light + "color", light.Color); + volumetricShader->SetUniformVec3(u_light + "direction", light.GetDirection()); + + volumetricShader->SetUniformTex(u_light + "shadowmap", light.m_Framebuffers[0]->GetTexture(GL_DEPTH_ATTACHMENT).get(), 1 + i); + } + + Renderer::DrawQuad(); + mFinalFramebuffer->Unbind(); + } +} \ No newline at end of file diff --git a/Nuake/src/Rendering/PostFX/Volumetric.h b/Nuake/src/Rendering/PostFX/Volumetric.h new file mode 100644 index 00000000..d607f2bb --- /dev/null +++ b/Nuake/src/Rendering/PostFX/Volumetric.h @@ -0,0 +1,43 @@ +#pragma once +#include "src/Core/Core.h" +#include "src/Core/Maths.h" +#include "src/Rendering/Buffers/FrameBuffer.h" +#include "src/Scene/Components/LightComponent.h" +#include + +namespace Nuake { + class Volumetric + { + private: + uint32_t mStepCount = 50; + float mRenderRatio = 1.0f; + float mFogAmount = 0.9f; + + Vector2 mSize; + Texture* mDepth; + Scope mFinalFramebuffer; + + public: + Volumetric(); + + void SetDepth(Texture* depth); + void Init(); + void Resize(Vector2 size); + void Draw(Matrix4 projection, Matrix4 view, std::vector& lights); + + inline int GetStepCount() const { return mStepCount;} + + inline void SetStepCount(unsigned int amount) { mStepCount = amount; } + + inline float GetFogAmount() const { return mFogAmount; } + void SetFogAmount(float amount) + { + if (amount > 0) mFogAmount = amount; + } + + Texture* GetFinalOutput() + { + return mFinalFramebuffer->GetTexture().get(); + } + }; +} \ No newline at end of file diff --git a/Nuake/src/Rendering/Renderer.cpp b/Nuake/src/Rendering/Renderer.cpp index 365b96d9..c4d28759 100644 --- a/Nuake/src/Rendering/Renderer.cpp +++ b/Nuake/src/Rendering/Renderer.cpp @@ -131,7 +131,7 @@ namespace Nuake int idx = m_Lights.size(); Vector3 direction = light.GetDirection(); - Vector3 pos = transform.GetGlobalTransform()[3]; + Vector3 pos = transform.GlobalTranslation; Matrix4 lightView = glm::lookAt(pos, pos - direction, glm::vec3(0.0f, 1.0f, 0.0f)); //light.m_Framebuffer->GetTexture(GL_DEPTH_ATTACHMENT)->Bind(17); @@ -152,8 +152,7 @@ namespace Nuake deferredShader->SetUniform1i("LightCount", idx); deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].Type", light.Type); - deferredShader->SetUniformMat4f("Lights[" + std::to_string(idx - 1) + "].LightTransform", light.GetProjection() * lightView); - deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Position",pos.x, pos.y, pos.z); + deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Position", pos.x, pos.y, pos.z); deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Direction", direction.x, direction.y, direction.z); deferredShader->SetUniform3f("Lights[" + std::to_string(idx - 1) + "].Color", light.Color.r * light.Strength, light.Color.g * light.Strength, light.Color.b * light.Strength); deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].Volumetric", light.IsVolumetric); diff --git a/Nuake/src/Rendering/SceneRenderer.cpp b/Nuake/src/Rendering/SceneRenderer.cpp index fa9eb6a3..2df48371 100644 --- a/Nuake/src/Rendering/SceneRenderer.cpp +++ b/Nuake/src/Rendering/SceneRenderer.cpp @@ -3,6 +3,7 @@ #include #include + namespace Nuake { void SceneRenderer::Init() { @@ -19,6 +20,8 @@ namespace Nuake { mBloom = CreateScope(4); mBloom->SetSource(shadedTexture); + + mVolumetric = CreateScope(); } void SceneRenderer::Cleanup() @@ -46,12 +49,25 @@ namespace Nuake { scene.GetEnvironment()->mBloom->Resize(framebuffer.GetSize()); scene.GetEnvironment()->mBloom->Draw(); + auto view = scene.m_Registry.view(); + std::vector lightList = std::vector(); + for (auto l : view) + { + auto& lc = view.get(l); + if (lc.Type == Directional && lc.IsVolumetric) + lightList.push_back(lc); + } + + + mVolumetric->Resize(framebuffer.GetSize()); + mVolumetric->SetDepth(mGBuffer->GetTexture(GL_DEPTH_ATTACHMENT).get()); + mVolumetric->Draw(mProjection, mView, lightList); + // Copy final output to target framebuffer framebuffer.Bind(); { Shader* shader = ShaderManager::GetShader("resources/Shaders/copy.shader"); shader->Bind(); - shader->SetUniformTex("u_Source", scene.GetEnvironment()->mBloom->GetOutput().get()); Renderer::DrawQuad(); } @@ -171,8 +187,6 @@ namespace Nuake { shadingShader->SetUniformVec3("u_EyePosition", mView[3]); Ref env = scene.GetEnvironment(); - shadingShader->SetUniform1f("u_FogAmount", env->VolumetricFog); - shadingShader->SetUniform1f("u_FogStepCount", env->VolumetricStepCount); auto view = scene.m_Registry.view(); for (auto l : view) diff --git a/Nuake/src/Rendering/SceneRenderer.h b/Nuake/src/Rendering/SceneRenderer.h index 96cf1a2e..467bacd5 100644 --- a/Nuake/src/Rendering/SceneRenderer.h +++ b/Nuake/src/Rendering/SceneRenderer.h @@ -5,6 +5,8 @@ #include "src/Scene/Scene.h" #include "src/Rendering/Buffers/Framebuffer.h" #include "src/Rendering/PostFX/Bloom.h" +#include "src/Rendering/PostFX/Volumetric.h" + namespace Nuake { class SceneRenderer { public: @@ -19,6 +21,7 @@ namespace Nuake { Scope mGBuffer; Scope mShadingBuffer; Scope mBloom; + Scope mVolumetric; void ShadowPass(Scene& scene); void GBufferPass(Scene& scene); diff --git a/Nuake/src/Rendering/Shaders/Shader.cpp b/Nuake/src/Rendering/Shaders/Shader.cpp index 30414689..85158916 100644 --- a/Nuake/src/Rendering/Shaders/Shader.cpp +++ b/Nuake/src/Rendering/Shaders/Shader.cpp @@ -34,13 +34,13 @@ namespace Nuake enum class ShaderType { - NONE = -1, VERTEX = 0, FRAGMENT = 1 + NONE = -1, VERTEX = 0, FRAGMENT = 1, GEOMETRY = 2, COMPUTE = 3 }; ShaderType type = ShaderType::NONE; std::string line; - std::stringstream ss[2]; + std::stringstream ss[4]; while (getline(stream, line)) { @@ -58,6 +58,14 @@ namespace Nuake // set mode to fragment type = ShaderType::FRAGMENT; } + else if (line.find("geometry") != std::string::npos) + { + type = ShaderType::GEOMETRY; + } + else if (line.find("compute") != std::string::npos) + { + type = ShaderType::COMPUTE; + } } else { @@ -65,7 +73,7 @@ namespace Nuake } } - return { ss[0].str(), ss[1].str() }; + return { ss[0].str(), ss[1].str(), ss[2].str(), ss[3].str() }; } // Parse both source and creates a shader program. @@ -73,8 +81,23 @@ namespace Nuake unsigned int Shader::CreateProgram() { unsigned int program = glCreateProgram(); + unsigned int vs = Compile(GL_VERTEX_SHADER); unsigned int fs = Compile(GL_FRAGMENT_SHADER); + unsigned int gs = 0; + unsigned int cs = 0; + + if (Source.GeometryShader != "") + { + gs = Compile(GL_GEOMETRY_SHADER); + glAttachShader(program, gs); + } + + if (Source.ComputeShader != "") + { + cs = Compile(GL_COMPUTE_SHADER); + glAttachShader(program, cs); + } glAttachShader(program, vs); glAttachShader(program, fs); @@ -84,6 +107,11 @@ namespace Nuake glDeleteShader(vs); glDeleteShader(fs); + if (gs != 0) + glDeleteShader(gs); + if (cs != 0) + glDeleteShader(cs); + return program; } @@ -95,6 +123,8 @@ namespace Nuake const char* src; if (type == GL_FRAGMENT_SHADER) src = Source.FragmentShader.c_str(); if (type == GL_VERTEX_SHADER) src = Source.VertexShader.c_str(); + if (type == GL_GEOMETRY_SHADER) src = Source.GeometryShader.c_str(); + if (type == GL_COMPUTE_SHADER) src = Source.ComputeShader.c_str(); glShaderSource(id, 1, &src, nullptr); glCompileShader(id); @@ -115,10 +145,16 @@ namespace Nuake glGetShaderInfoLog(id, length, &length, message); + std::string stype; + if (type == GL_FRAGMENT_SHADER) stype = "Fragment"; + if (type == GL_VERTEX_SHADER) stype = "Vertex"; + if (type == GL_GEOMETRY_SHADER) stype = "Geometry"; + if (type == GL_COMPUTE_SHADER) stype = "Compute"; + std::cout << "Failed to compile " << (type == GL_VERTEX_SHADER ? "vertex" : "Fragment") << " shader!" << std::endl; - std::cout << message << std::endl; + std::cout << message << std::endl; // Delete invalid shader glDeleteShader(id); return 0; diff --git a/Nuake/src/Rendering/Shaders/Shader.h b/Nuake/src/Rendering/Shaders/Shader.h index e167b2d3..fdf45238 100644 --- a/Nuake/src/Rendering/Shaders/Shader.h +++ b/Nuake/src/Rendering/Shaders/Shader.h @@ -13,6 +13,8 @@ namespace Nuake { std::string VertexShader; std::string FragmentShader; + std::string GeometryShader; + std::string ComputeShader; }; class Shader @@ -28,8 +30,6 @@ namespace Nuake void Bind() const; void Unbind() const; - - // Todo: Other uniform types. void SetUniformVec4(const std::string& name, Vector4 vec); void SetUniformVec3(const std::string& name, Vector3 vec); void SetUniformVec2(const std::string& name, Vector2 vec); diff --git a/Nuake/src/Scene/Components/MeshComponent.cpp b/Nuake/src/Scene/Components/MeshComponent.cpp index a7b85bce..45171530 100644 --- a/Nuake/src/Scene/Components/MeshComponent.cpp +++ b/Nuake/src/Scene/Components/MeshComponent.cpp @@ -11,6 +11,14 @@ namespace Nuake { Assimp::Importer import; import.SetPropertyFloat("PP_GSN_MAX_SMOOTHING_ANGLE", 90); const aiScene* scene = import.ReadFile(FileSystem::Root + ModelPath, aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FixInfacingNormals | aiProcess_CalcTangentSpace); + + + directory = ""; + std::vector path = String::Split(ModelPath, '/'); + for (int i = 0; i < path.size(); i++) + if (i < path.size() - 1) + directory += path[i] + '/'; + if (scene->HasTextures()) { int textureCount = scene->mNumTextures; @@ -96,44 +104,95 @@ namespace Nuake { } // process material - if (mesh->mMaterialIndex >= 0) + if (mesh->mMaterialIndex < 0) + return nullptr; + + aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex]; + Ref newMaterial = MaterialManager::Get()->GetMaterial(directory + std::to_string(mesh->mMaterialIndex) + material->GetName().C_Str()); + + aiString str; + + unsigned int textureCount = material->GetTextureCount(aiTextureType_DIFFUSE); + material->GetTexture(aiTextureType_DIFFUSE, 0, &str); + + // Embedded texture + if (String::BeginsWith(str.C_Str(), "*")) { - aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex]; - Ref newMaterial = MaterialManager::Get()->GetMaterial(material->GetName().C_Str()); + int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); + const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); - aiString str; - - unsigned int textureCount = material->GetTextureCount(aiTextureType_DIFFUSE); - material->GetTexture(aiTextureType_DIFFUSE, 0, &str); - - // Embedded texture - if (String::BeginsWith(str.C_Str(), "*")) - { - int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); - const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); - - Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); - newMaterial->SetAlbedo(newTexture); - } - - - //material->GetTexture(aiTextureType_NORMALS, 0, &str); - //newMaterial->SetNormal(TextureManager::Get()->GetTexture(directory + str.C_Str())); - - //material->GetTexture(aiTextureType_METALNESS, 0, &str); - //newMaterial->SetMetalness(TextureManager::Get()->GetTexture(directory + str.C_Str())); - - //material->GetTexture(aiTextureType_DIFFUSE_ROUGHNESS, 0, &str); - //newMaterial->SetRoughness(TextureManager::Get()->GetTexture(directory + str.C_Str())); - - //material->GetTexture(aiTextureType_DISPLACEMENT, 0, &str); - //newMaterial->SetDisplacement(TextureManager::Get()->GetTexture(directory + str.C_Str())); - - //material->GetTexture(aiTextureType_AMBIENT_OCCLUSION, 0, &str); - //newMaterial->SetAO(TextureManager::Get()->GetTexture(directory + str.C_Str())); - - return CreateRef(vertices, indices, newMaterial); + Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); + newMaterial->SetAlbedo(newTexture); } + else + { + newMaterial->SetAlbedo(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str())); + } + + material->GetTexture(aiTextureType_NORMALS, 0, &str); + if (String::BeginsWith(str.C_Str(), "*")) + { + int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); + const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); + + Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); + newMaterial->SetNormal(newTexture); + } + else + { + newMaterial->SetNormal(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str())); + } + //newMaterial->SetNormal(TextureManager::Get()->GetTexture(directory + str.C_Str())); + + material->GetTexture(aiTextureType_METALNESS, 0, &str); + if (String::BeginsWith(str.C_Str(), "*")) + { + int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); + const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); + + Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); + newMaterial->SetMetalness(newTexture); + } + else + { + newMaterial->SetMetalness(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str())); + } + //newMaterial->SetMetalness(TextureManager::Get()->GetTexture(directory + str.C_Str())); + + material->GetTexture(aiTextureType_DIFFUSE_ROUGHNESS, 0, &str); + if (String::BeginsWith(str.C_Str(), "*")) + { + int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); + const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); + + Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); + newMaterial->SetRoughness(newTexture); + } + else + { + newMaterial->SetRoughness(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str())); + } + //newMaterial->SetRoughness(TextureManager::Get()->GetTexture(directory + str.C_Str())); + + //material->GetTexture(aiTextureType_DISPLACEMENT, 0, &str); + //newMaterial->SetDisplacement(TextureManager::Get()->GetTexture(directory + str.C_Str())); + + material->GetTexture(aiTextureType_AMBIENT_OCCLUSION, 0, &str); + if (String::BeginsWith(str.C_Str(), "*")) + { + int textureIndex = std::atoi(String::Split(str.C_Str(), '*')[1].c_str()); + const aiTexture* texture = scene->GetEmbeddedTexture(str.C_Str()); + + Ref newTexture = CreateRef(Vector2(texture->mWidth, texture->mHeight), (unsigned char*)texture->pcData, texture->mWidth); + newMaterial->SetAO(newTexture); + } + else + { + newMaterial->SetAO(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str())); + } + //newMaterial->SetAO(TextureManager::Get()->GetTexture(directory + str.C_Str())); + + return CreateRef(vertices, indices, newMaterial); } std::vector MeshComponent::LoadMaterialTextures(aiMaterial* mat, aiTextureType type) diff --git a/Nuake/src/Scene/EditorCamera.cpp b/Nuake/src/Scene/EditorCamera.cpp index f7b0970a..c69c3101 100644 --- a/Nuake/src/Scene/EditorCamera.cpp +++ b/Nuake/src/Scene/EditorCamera.cpp @@ -52,18 +52,18 @@ namespace Nuake glm::vec3 movement = glm::vec3(0, 0, 0); if (Input::IsKeyDown(GLFW_KEY_D)) - movement -= cameraRight * (Speed * ts); + movement -= Right * (Speed * ts); if (Input::IsKeyDown(GLFW_KEY_A)) - movement += cameraRight * (Speed * ts); + movement += Right * (Speed * ts); if (Input::IsKeyDown(GLFW_KEY_W)) - movement += cameraDirection * (Speed * ts); + movement += Direction * (Speed * ts); if (Input::IsKeyDown(GLFW_KEY_S)) - movement -= cameraDirection * (Speed * ts); + movement -= Direction * (Speed * ts); if (Input::IsKeyDown(GLFW_KEY_LEFT_SHIFT)) - movement -= up * (Speed * ts); + movement -= Up * (Speed * ts); if (Input::IsKeyDown(GLFW_KEY_SPACE)) - movement += up * (Speed * ts); + movement += Up * (Speed * ts); Translation += Vector3(movement); } @@ -93,10 +93,10 @@ namespace Nuake if (Pitch < -89.0f) Pitch = -89.0f; - cameraDirection.x = cos(glm::radians(Yaw)) * cos(glm::radians(Pitch)); - cameraDirection.y = sin(glm::radians(Pitch)); - cameraDirection.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch)); - cameraFront = glm::normalize(cameraDirection); - cameraRight = glm::normalize(glm::cross(up, cameraFront)); + Direction.x = cos(glm::radians(Yaw)) * cos(glm::radians(Pitch)); + Direction.y = sin(glm::radians(Pitch)); + Direction.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch)); + Direction = glm::normalize(Direction); + Right = glm::normalize(glm::cross(Up, Direction)); } } diff --git a/Nuake/src/Scene/Entities/ImGuiHelper.h b/Nuake/src/Scene/Entities/ImGuiHelper.h index eb6649b8..93f3720b 100644 --- a/Nuake/src/Scene/Entities/ImGuiHelper.h +++ b/Nuake/src/Scene/Entities/ImGuiHelper.h @@ -12,32 +12,28 @@ public: auto boldFont = io.Fonts->Fonts[0]; ImGui::PushID(label.c_str()); - - ImGui::Columns(2); - ImGui::SetColumnWidth(0, columnWidth); - ImGui::Text(label.c_str()); - ImGui::NextColumn(); - - ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth()); + + float availWidth = (ImGui::GetContentRegionAvailWidth() / 3.0) - 9.0; ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 0 }); - + float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f; - ImVec2 buttonSize = { lineHeight + 3.0f, lineHeight }; - + ImVec2 buttonSize = { 3.0f, lineHeight }; + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f }); ImGui::PushFont(boldFont); - if (ImGui::Button("X", buttonSize)) + if (ImGui::Button("###X", buttonSize)) values->x = resetValue; ImGui::PopFont(); ImGui::PopStyleColor(3); - + ImGui::SameLine(); + ImGui::PushItemWidth(availWidth); ImGui::DragFloat("##X", &values->x, 0.1f, 0.0f, 0.0f, "%.2f"); ImGui::PopItemWidth(); ImGui::SameLine(); - + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f }); @@ -46,12 +42,12 @@ public: values->y = resetValue; ImGui::PopFont(); ImGui::PopStyleColor(3); - ImGui::SameLine(); + ImGui::PushItemWidth(availWidth); ImGui::DragFloat("##Y", &values->y, 0.1f, 0.0f, 0.0f, "%.2f"); ImGui::PopItemWidth(); ImGui::SameLine(); - + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f, 0.35f, 0.9f, 1.0f }); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f }); @@ -60,15 +56,15 @@ public: values->z = resetValue; ImGui::PopFont(); ImGui::PopStyleColor(3); - ImGui::SameLine(); + + ImGui::PushItemWidth(availWidth); ImGui::DragFloat("##Z", &values->z, 0.1f, 0.0f, 0.0f, "%.2f"); ImGui::PopItemWidth(); - + ImGui::PopStyleVar(); - - ImGui::Columns(1); - + ImGui::PopID(); + //ImGui::Text("Hello"); } }; \ No newline at end of file diff --git a/Nuake/src/Scripting/Modules/SceneModule.h b/Nuake/src/Scripting/Modules/SceneModule.h index ad18e161..dd982a84 100644 --- a/Nuake/src/Scripting/Modules/SceneModule.h +++ b/Nuake/src/Scripting/Modules/SceneModule.h @@ -184,7 +184,7 @@ namespace Nuake { auto& cam = ent.GetComponent(); - Vector3 right = cam.CameraInstance->cameraRight; + Vector3 right = cam.CameraInstance->GetRight(); // set the slots wrenSetSlotDouble(vm, 1, right.x); diff --git a/Nuake/src/Vendors/imgui/imgui.cpp b/Nuake/src/Vendors/imgui/imgui.cpp index bbe9a7fa..ad184216 100644 --- a/Nuake/src/Vendors/imgui/imgui.cpp +++ b/Nuake/src/Vendors/imgui/imgui.cpp @@ -14561,7 +14561,7 @@ ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f)); + PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.0f, 8.0f)); Begin(label, NULL, host_window_flags); PopStyleVar(3); diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index ba708582..746e7c42 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -145,62 +145,84 @@ namespace Nuake { ImGuiIO& io = ImGui::GetIO(); (void)io; //io.Fonts->AddFontDefault(); io.Fonts->AddFontFromFileTTF("resources/Fonts/OpenSans-Regular.ttf", 16.0); + io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; ImGui::StyleColorsDark(); - ImGui::GetStyle().FrameRounding = 2.0f; - ImGui::GetStyle().GrabRounding = 2.0f; + ImGuiStyle& s = ImGui::GetStyle(); + s.FrameRounding = 2.0f; + s.GrabRounding = 2.0f; + s.CellPadding = ImVec2(8, 8); + s.WindowPadding = ImVec2(8, 8); + s.ScrollbarRounding = 9.0f; + s.TabRounding = 0; + s.WindowRounding = 0; + s.ChildRounding = 0; + s.FrameRounding = 0; + s.GrabRounding = 0; + s.FramePadding = ImVec2(8, 4); + s.ItemSpacing = ImVec2(8, 4); + s.ItemInnerSpacing = ImVec2(4, 4); ImVec4* colors = ImGui::GetStyle().Colors; - colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); + colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); - colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f); - colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f); + colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); - colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); - colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.34f, 0.34f, 0.34f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.22f, 0.22f, 0.22f, 1.00f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.18f, 0.18f, 0.18f, 1.00f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f); + colors[ImGuiCol_Separator] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.10f, 0.10f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.00f); + colors[ImGuiCol_Tab] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_TabHovered] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); + colors[ImGuiCol_TabActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); + colors[ImGuiCol_TabUnfocused] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); + colors[ImGuiCol_DockingPreview] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f); + colors[ImGuiCol_DockingEmptyBg] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); + colors[ImGuiCol_TableBorderStrong] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); + colors[ImGuiCol_TableBorderLight] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); + colors[ImGuiCol_TableRowBg] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); + colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.93f, 0.27f, 0.27f, 0.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.08f, 0.49f, 0.97f, 0.28f); + colors[ImGuiCol_DragDropTarget] = ImVec4(0.55f, 0.76f, 0.29f, 1.00f); colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + + ImGui_ImplGlfw_InitForOpenGL(m_Window, true); ImGui_ImplOpenGL3_Init("#version 330"); }