mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-03 14:09:46 +03:00
Huge rework of editor and other changes.
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "src/NewEditor.h"
|
||||
#include <src/Scene/Components/BSPBrushComponent.h>
|
||||
|
||||
std::string WindowTitle = "Nuake Engine";
|
||||
|
||||
void OpenProject()
|
||||
{
|
||||
// Parse the project and load it.
|
||||
@@ -45,6 +47,16 @@ void OpenProject()
|
||||
//Engine::GetCurrentScene()->AddInterface(userInterface);
|
||||
}
|
||||
|
||||
std::vector<Nuake::LineVertex> vertices
|
||||
{
|
||||
Nuake::LineVertex {{10000.f, 0.0f, 0.0f}, {1.f, 0.f, 0.f, 1.f}},
|
||||
Nuake::LineVertex {{0.0f, 0.0f, 0.0f }, {1.f, 0.f, 0.f, 1.f}},
|
||||
Nuake::LineVertex {{0.f, 0.f, 10000.f }, {0.f, 1.f, 0.f, 1.f}},
|
||||
Nuake::LineVertex {{0.0f, 0.0f, 0.0f }, {0.f, 1.f, 0.f, 1.f}},
|
||||
Nuake::LineVertex {{0.f, 10000.f, 0.0f }, {0.f, 0.f, 1.f, 1.f}},
|
||||
Nuake::LineVertex {{0.0f, 0.0f, 0.0f }, {0.f, 0.f, 1.f, 1.f}}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Nuake::Engine::Init();
|
||||
@@ -52,6 +64,20 @@ int main()
|
||||
Nuake::EditorInterface editor;
|
||||
editor.BuildFonts();
|
||||
|
||||
glLineWidth(2.0f);
|
||||
|
||||
Nuake::Shader* lineShader = Nuake::ShaderManager::GetShader("resources/Shaders/line.shader");
|
||||
|
||||
lineShader->Bind();
|
||||
|
||||
Nuake::VertexArray* lineVertexArray = new Nuake::VertexArray();
|
||||
lineVertexArray->Bind();
|
||||
Nuake::VertexBuffer* lineVertexBuffer = new Nuake::VertexBuffer(vertices.data(), vertices.size() * sizeof(Nuake::LineVertex));
|
||||
Nuake::VertexBufferLayout* vblayout = new Nuake::VertexBufferLayout();
|
||||
vblayout->Push<float>(3);
|
||||
vblayout->Push<float>(4);
|
||||
lineVertexArray->AddBuffer(*lineVertexBuffer, *vblayout);
|
||||
|
||||
// Register Gizmo textures
|
||||
Ref<Nuake::Texture> lightTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Light.png");
|
||||
Ref<Nuake::Texture> camTexture = Nuake::TextureManager::Get()->GetTexture("resources/Icons/Gizmo/Camera.png");
|
||||
@@ -59,80 +85,110 @@ int main()
|
||||
Nuake::Shader* ditherShader = Nuake::ShaderManager::GetShader("resources/Shaders/dither.shader");
|
||||
|
||||
//Nuake::NewEditor newEditor = Nuake::NewEditor();
|
||||
|
||||
// Register shaders
|
||||
while (!Nuake::Engine::GetCurrentWindow()->ShouldClose())
|
||||
{
|
||||
Nuake::RenderCommand::Clear();
|
||||
Nuake::Engine::Tick();
|
||||
Ref<Nuake::Window> window = Nuake::Engine::GetCurrentWindow();
|
||||
window->SetTitle("Nuake Editor");
|
||||
|
||||
while (!window->ShouldClose())
|
||||
{
|
||||
Nuake::Engine::Tick();
|
||||
Nuake::Engine::Draw();
|
||||
|
||||
//newEditor.Update(0.f);
|
||||
|
||||
|
||||
|
||||
Nuake::Vector2 WindowSize = Nuake::Engine::GetCurrentWindow()->GetSize();
|
||||
Nuake::Vector2 WindowSize = window->GetSize();
|
||||
glViewport(0, 0, WindowSize.x, WindowSize.y);
|
||||
Nuake::Renderer2D::BeginDraw(WindowSize);
|
||||
|
||||
//newEditor.Draw(WindowSize);
|
||||
|
||||
Ref<Nuake::FrameBuffer> sceneFramebuffer = Nuake::Engine::GetCurrentWindow()->GetFrameBuffer();
|
||||
Ref<Nuake::FrameBuffer> sceneFramebuffer = window->GetFrameBuffer();
|
||||
sceneFramebuffer->Bind();
|
||||
|
||||
|
||||
Ref<Nuake::Scene> currentScene = Nuake::Engine::GetCurrentScene();
|
||||
if (currentScene && !Nuake::Engine::IsPlayMode)
|
||||
{
|
||||
//GuizmoShader->Bind();
|
||||
//
|
||||
//glDisable(GL_CULL_FACE);
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
//auto camView = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::CameraComponent>();
|
||||
//for (auto e : camView) {
|
||||
// auto [transformComponent, cam] = camView.get<Nuake::TransformComponent, Nuake::CameraComponent>(e);
|
||||
//
|
||||
// GuizmoShader->SetUniformMat4f("model", transformComponent.GetGlobalTransform());
|
||||
// GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
// GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
//
|
||||
// camTexture->Bind(2);
|
||||
// GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
//
|
||||
// Nuake::Renderer::DrawQuad(transformComponent.GetGlobalTransform());
|
||||
//}
|
||||
//
|
||||
//auto view = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::LightComponent>();
|
||||
//for (auto e : view) {
|
||||
// auto [transformComponent, light] = view.get<Nuake::TransformComponent, Nuake::LightComponent>(e);
|
||||
//
|
||||
// GuizmoShader->SetUniformMat4f("model", transformComponent.GetGlobalTransform());
|
||||
// GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
// GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
//
|
||||
// lightTexture->Bind(2);
|
||||
// GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
//
|
||||
// Nuake::Renderer::DrawQuad(transformComponent.GetGlobalTransform());
|
||||
//}
|
||||
//
|
||||
//glEnable(GL_CULL_FACE);
|
||||
//
|
||||
//GuizmoShader->Unbind();
|
||||
//
|
||||
//ditherShader->Bind();
|
||||
//ditherShader->SetUniformMat4f("u_View", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetTransform());
|
||||
//ditherShader->SetUniformMat4f("u_Projection", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetPerspective());
|
||||
//ditherShader->SetUniform1f("u_Time", Nuake::Engine::GetTime());
|
||||
//ditherShader->SetUniform4f("u_Color", 252.0 / 255.0, 3.0 / 255.0, 65.0 / 255.0, 1.0);
|
||||
//
|
||||
//if (editor.m_IsEntitySelected && editor.m_SelectedEntity.HasComponent<Nuake::BSPBrushComponent>())
|
||||
//{
|
||||
// for (auto& m : editor.m_SelectedEntity.GetComponent<Nuake::BSPBrushComponent>().Meshes)
|
||||
// Nuake::Renderer::SubmitMesh(m, editor.m_SelectedEntity.GetComponent<Nuake::TransformComponent>().GetGlobalTransform());
|
||||
//
|
||||
// Nuake::Renderer::Flush(ditherShader, true);
|
||||
//}
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
lineShader->Bind();
|
||||
lineShader->SetUniformMat4f("u_View", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetTransform());
|
||||
lineShader->SetUniformMat4f("u_Projection", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetPerspective());
|
||||
|
||||
lineVertexArray->Bind();
|
||||
Nuake::RenderCommand::DrawLines(0, 6);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
GuizmoShader->Bind();
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
auto camView = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::CameraComponent>();
|
||||
for (auto e : camView) {
|
||||
auto [transformComponent, cam] = camView.get<Nuake::TransformComponent, Nuake::CameraComponent>(e);
|
||||
|
||||
Nuake::Vector3 cameraPos = currentScene->m_EditorCamera->GetTranslation();
|
||||
Nuake::Vector3 position = transformComponent.GlobalTranslation;
|
||||
Nuake::Vector3 look = normalize(cameraPos - position);
|
||||
Nuake::Vector3 right = glm::cross(currentScene->m_EditorCamera->GetUp(), look);
|
||||
Nuake::Vector3 up2 = currentScene->m_EditorCamera->GetUp();
|
||||
Nuake::Matrix4 transform = glm::identity<Nuake::Matrix4>();
|
||||
transform[0] = Nuake::Vector4(right, 0);
|
||||
transform[1] = Nuake::Vector4(up2, 0);
|
||||
transform[2] = Nuake::Vector4(look, 0);
|
||||
transform = glm::translate(transform, position);
|
||||
GuizmoShader->SetUniformMat4f("model", transform);
|
||||
GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
|
||||
camTexture->Bind(2);
|
||||
GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
|
||||
Nuake::Renderer::DrawQuad(transformComponent.GetGlobalTransform());
|
||||
}
|
||||
|
||||
auto view = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::LightComponent>();
|
||||
for (auto e : view) {
|
||||
auto [transformComponent, light] = view.get<Nuake::TransformComponent, Nuake::LightComponent>(e);
|
||||
|
||||
GuizmoShader->SetUniformMat4f("model", transformComponent.GetGlobalTransform());
|
||||
GuizmoShader->SetUniformMat4f("view", currentScene->m_EditorCamera->GetTransform());
|
||||
GuizmoShader->SetUniformMat4f("projection", currentScene->m_EditorCamera->GetPerspective());
|
||||
|
||||
lightTexture->Bind(2);
|
||||
GuizmoShader->SetUniform1i("gizmo_texture", 2);
|
||||
|
||||
Nuake::Renderer::DrawQuad(transformComponent.GetGlobalTransform());
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
GuizmoShader->Unbind();
|
||||
|
||||
ditherShader->Bind();
|
||||
ditherShader->SetUniformMat4f("u_View", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetTransform());
|
||||
ditherShader->SetUniformMat4f("u_Projection", Nuake::Engine::GetCurrentScene()->m_EditorCamera->GetPerspective());
|
||||
ditherShader->SetUniform1f("u_Time", Nuake::Engine::GetTime());
|
||||
ditherShader->SetUniform4f("u_Color", 252.0 / 255.0, 3.0 / 255.0, 65.0 / 255.0, 1.0);
|
||||
|
||||
if (editor.m_IsEntitySelected && editor.m_SelectedEntity.HasComponent<Nuake::BSPBrushComponent>())
|
||||
{
|
||||
for (auto& m : editor.m_SelectedEntity.GetComponent<Nuake::BSPBrushComponent>().Meshes)
|
||||
Nuake::Renderer::SubmitMesh(m, editor.m_SelectedEntity.GetComponent<Nuake::TransformComponent>().GetGlobalTransform());
|
||||
|
||||
Nuake::Renderer::Flush(ditherShader, true);
|
||||
}
|
||||
|
||||
ditherShader->SetUniform1f("u_Time", Nuake::Engine::GetTime() / 10.0f);
|
||||
ditherShader->SetUniform4f("u_Color", 52.f / 255.f, 235.f / 255.f, 88.f / 255.f, 1);
|
||||
auto cubeCollidersView = currentScene->m_Registry.view<Nuake::TransformComponent, Nuake::BoxColliderComponent>();
|
||||
if (editor.m_IsEntitySelected && editor.m_SelectedEntity.HasComponent<Nuake::BoxColliderComponent>())
|
||||
{
|
||||
auto transformComponent = editor.m_SelectedEntity.GetComponent<Nuake::TransformComponent>();
|
||||
auto colliderComponent = editor.m_SelectedEntity.GetComponent<Nuake::BoxColliderComponent>();
|
||||
Nuake::Matrix4 transform = transformComponent.GetGlobalTransform();
|
||||
transform = glm::scale(transform, colliderComponent.Size);
|
||||
Nuake::Renderer::SubmitCube(transform);
|
||||
|
||||
Nuake::Renderer::Flush(ditherShader, true);
|
||||
}
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
sceneFramebuffer->Unbind();
|
||||
|
||||
@@ -103,7 +103,7 @@ class Vector3 {
|
||||
}
|
||||
|
||||
Cross(vec) {
|
||||
Math.Cross(this, vec)
|
||||
return Math.Cross(this, vec)
|
||||
}
|
||||
|
||||
Normalize() {
|
||||
|
||||
@@ -19,7 +19,8 @@ uniform int u_Stage;
|
||||
|
||||
uniform sampler2D u_Source;
|
||||
uniform vec2 u_SourceSize;
|
||||
|
||||
uniform float u_Exposure;
|
||||
uniform float u_Gamma;
|
||||
uniform sampler2D u_Source2;
|
||||
uniform vec2 u_Source2Size;
|
||||
|
||||
@@ -99,28 +100,7 @@ vec4 blur9(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
return color;
|
||||
}
|
||||
|
||||
vec3 acesOperator(vec3 rgbColour)
|
||||
{
|
||||
const mat3 inputMatrix = mat3
|
||||
(
|
||||
vec3(0.59719, 0.07600, 0.02840),
|
||||
vec3(0.35458, 0.90834, 0.13383),
|
||||
vec3(0.04823, 0.01566, 0.83777)
|
||||
);
|
||||
|
||||
const mat3 outputMatrix = mat3
|
||||
(
|
||||
vec3(1.60475, -0.10208, -0.00327),
|
||||
vec3(-0.53108, 1.10813, -0.07276),
|
||||
vec3(-0.07367, -0.00605, 1.07602)
|
||||
);
|
||||
|
||||
vec3 inputColour = inputMatrix * rgbColour;
|
||||
vec3 a = inputColour * (inputColour + vec3(0.0245786)) - vec3(0.000090537);
|
||||
vec3 b = inputColour * (0.983729 * inputColour + 0.4329510) + 0.238081;
|
||||
vec3 c = a / b;
|
||||
return outputMatrix * c;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
@@ -150,15 +130,7 @@ void main()
|
||||
outputColor += texture(u_Source2, UV);
|
||||
|
||||
vec3 color = outputColor.rgb;
|
||||
|
||||
//color = acesOperator(color);
|
||||
|
||||
color = color / (color + vec3(2.0));
|
||||
color = vec3(1.0) - exp(-color * 1.0);
|
||||
color = pow(color, vec3(1.0 / 2.2));
|
||||
|
||||
outputColor = vec4(color, 1.0);//vec4(acesOperator(outputColor.rgb), 1.0f);
|
||||
|
||||
}
|
||||
FragColor = outputColor;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void main()
|
||||
|
||||
// scale light by NdotL
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
Lo += (kD * albedo / PI + specular) * radiance * NdotL;// note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
|
||||
Lo += (kD * albedo / PI) * radiance * NdotL;// note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
|
||||
}
|
||||
|
||||
/// ambient lighting (we now use IBL as the ambient term)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#shader vertex
|
||||
#version 460 core
|
||||
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
|
||||
uniform mat4 u_Projection;
|
||||
|
||||
@@ -78,7 +78,7 @@ void main()
|
||||
if (u_HasAlbedo == 1)
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb;
|
||||
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb;
|
||||
gAlbedo.rgb = texture(m_Albedo, UV).rgb * m_AlbedoColor.rgb;
|
||||
|
||||
// Material
|
||||
float finalMetalness = u_MetalnessValue;
|
||||
|
||||
29
Editor/resources/Shaders/line.shader
Normal file
29
Editor/resources/Shaders/line.shader
Normal file
@@ -0,0 +1,29 @@
|
||||
#shader vertex
|
||||
#version 460 core
|
||||
|
||||
layout(location = 0) in vec3 VertexPosition;
|
||||
layout(location = 0) in vec4 VertexColor;
|
||||
|
||||
uniform mat4 u_Projection;
|
||||
uniform mat4 u_View;
|
||||
uniform mat4 u_Model;
|
||||
|
||||
out vec4 LineColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
LineColor = VertexColor;
|
||||
gl_Position = u_Projection * u_View * vec4(VertexPosition, 1.0f);
|
||||
}
|
||||
|
||||
#shader fragment
|
||||
#version 460 core
|
||||
|
||||
in vec4 LineColor;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = LineColor;
|
||||
}
|
||||
@@ -16,19 +16,32 @@ void main()
|
||||
#version 460 core
|
||||
|
||||
uniform sampler2D u_Source;
|
||||
uniform float u_Gamma;
|
||||
uniform float u_Exposure;
|
||||
|
||||
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec3 aces(vec3 x) {
|
||||
const float a = 2.51;
|
||||
const float b = 0.03;
|
||||
const float c = 2.43;
|
||||
const float d = 0.59;
|
||||
const float e = 0.14;
|
||||
return clamp((x * (a * x + b)) / (x * (c * x + d) + e), 0.0, 1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(u_Source, UV);
|
||||
vec3 color = texture(u_Source, UV).rgb;
|
||||
|
||||
color = mix(color, color * u_Exposure, 0.1f);
|
||||
// reinhard
|
||||
color = color / (color + vec3(1.0));
|
||||
const float gamma = 2.2;
|
||||
// HDR tonemapping
|
||||
color = vec3(1.0) - exp(-color * u_Exposure);
|
||||
// gamma correct
|
||||
color = pow(color, vec3(1.0 / gamma));
|
||||
FragColor = color;
|
||||
color = pow(color, vec3(1.0 / u_Gamma));
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
15
Editor/src/Actions/EditorAction.h
Normal file
15
Editor/src/Actions/EditorAction.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
enum ActionType
|
||||
{
|
||||
SAVE, TRANSLATE
|
||||
};
|
||||
|
||||
class EditorAction
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
virtual void Do() = 0;
|
||||
virtual void Undo() = 0;
|
||||
};
|
||||
@@ -280,7 +280,7 @@ namespace Nuake {
|
||||
void EditorInterface::DrawSceneTree()
|
||||
{
|
||||
Ref<Scene> scene = Engine::GetCurrentScene();
|
||||
|
||||
|
||||
if (!scene)
|
||||
return;
|
||||
|
||||
@@ -299,8 +299,14 @@ namespace Nuake {
|
||||
ImGuiHelper::DrawVec3("Mie Scattering", &mieScattering);
|
||||
env->ProceduralSkybox->MieScattering = mieScattering / 10000.0f;
|
||||
}
|
||||
if (ImGui::CollapsingHeader("HDR", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::DragFloat("Exposure", &env->Exposure, .01f, 0.0f, 10.0f);
|
||||
ImGui::DragFloat("Gamma", &env->Gamma, 0.1f, 0.0f, 10.0f);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Bloom", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Checkbox("Enabled", &env->BloomEnabled);
|
||||
float threshold = env->mBloom->GetThreshold();
|
||||
ImGui::DragFloat("Threshold", &threshold, 0.01f, 0.0f, 500.0f);
|
||||
env->mBloom->SetThreshold(threshold);
|
||||
@@ -311,6 +317,7 @@ namespace Nuake {
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Fog", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::Checkbox("Enabled", &env->VolumetricEnabled);
|
||||
ImGui::DragFloat("Volumetric Scattering", &env->VolumetricFog, .01f, 0.0f, 1.0f);
|
||||
ImGui::DragFloat("Volumetric Step Count", &env->VolumetricStepCount, 1.f, 0.0f);
|
||||
}
|
||||
@@ -340,7 +347,6 @@ namespace Nuake {
|
||||
// // Unselect delted entity.
|
||||
// m_SelectedEntity = scene->GetAllEntities().at(0);
|
||||
//}
|
||||
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -388,8 +394,6 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndChild();
|
||||
@@ -421,24 +425,33 @@ namespace Nuake {
|
||||
QueueDeletion = Entity{ (entt::entity)-1, scene.get() };
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void EditorInterface::DrawEntityPropreties()
|
||||
{
|
||||
if (ImGui::Begin("Propreties"))
|
||||
{
|
||||
if (!m_IsEntitySelected)
|
||||
{
|
||||
ImGui::Text("No entity selected");
|
||||
std::string text = "No entity selected";
|
||||
auto windowWidth = ImGui::GetWindowSize().x;
|
||||
auto windowHeight = ImGui::GetWindowSize().y;
|
||||
|
||||
auto textWidth = ImGui::CalcTextSize(text.c_str()).x;
|
||||
auto textHeight = ImGui::CalcTextSize(text.c_str()).y;
|
||||
ImGui::SetCursorPosX((windowWidth - textWidth) * 0.5f);
|
||||
ImGui::SetCursorPosY((windowHeight - textHeight) * 0.5f);
|
||||
|
||||
ImGui::PushFont(boldFont);
|
||||
ImGui::Text(text.c_str());
|
||||
ImGui::PopFont();
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_SelectedEntity.HasComponent<NameComponent>()) {
|
||||
auto& name = m_SelectedEntity.GetComponent<NameComponent>().Name;
|
||||
|
||||
@@ -612,10 +625,8 @@ namespace Nuake {
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
|
||||
if (m_SelectedEntity.HasComponent<MeshComponent>())
|
||||
{
|
||||
@@ -754,7 +765,13 @@ namespace Nuake {
|
||||
ImGui::Text("Cast Shadows");
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
// This will create framebuffers and textures.
|
||||
bool castShadows = component.CastShadows;
|
||||
ImGui::Checkbox("##CastShadows", &component.CastShadows);
|
||||
if (castShadows != component.CastShadows)
|
||||
component.SetCastShadows(castShadows);
|
||||
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
std::string resetShadow = ICON_FA_UNDO + std::string("##resetShadow");
|
||||
@@ -1086,14 +1103,16 @@ namespace Nuake {
|
||||
else
|
||||
{
|
||||
const char* icon = ICON_FA_FILE;
|
||||
|
||||
if (file->Type == ".shader")
|
||||
icon = ICON_FA_FILE_CODE;
|
||||
if (file->Type == ".map")
|
||||
else if (file->Type == ".map")
|
||||
icon = ICON_FA_BROOM;
|
||||
if (file->Type == ".ogg" || file->Type == ".mp3" || file->Type == ".wav" || file->Type == ".flac")
|
||||
else if (file->Type == ".ogg" || file->Type == ".mp3" || file->Type == ".wav" || file->Type == ".flac")
|
||||
icon = ICON_FA_FILE_AUDIO;
|
||||
if (file->Type == ".cpp" || file->Type == ".h" || file->Type == ".cs" || file->Type == ".py" || file->Type == ".lua")
|
||||
else if (file->Type == ".cpp" || file->Type == ".h" || file->Type == ".cs" || file->Type == ".py" || file->Type == ".lua")
|
||||
icon = ICON_FA_FILE_CODE;
|
||||
|
||||
if (ImGui::Button(icon, ImVec2(100, 100)))
|
||||
{
|
||||
if (ImGui::BeginPopupContextItem("item context menu"))
|
||||
@@ -1106,7 +1125,6 @@ namespace Nuake {
|
||||
}
|
||||
ImGui::Text(file->name.c_str());
|
||||
ImGui::PopFont();
|
||||
|
||||
}
|
||||
|
||||
void EditorInterface::DrawDirectoryExplorer()
|
||||
@@ -1367,7 +1385,7 @@ namespace Nuake {
|
||||
if (ImGui::CollapsingHeader("Roughness", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasRougness())
|
||||
if (material->HasRoughness())
|
||||
textureID = material->m_Roughness->GetID();
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -1506,7 +1524,7 @@ namespace Nuake {
|
||||
if (ImGui::CollapsingHeader("Roughness", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (m_SelectedMaterial->HasRougness())
|
||||
if (m_SelectedMaterial->HasRoughness())
|
||||
textureID = m_SelectedMaterial->m_Roughness->GetID();
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image5"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
@@ -1564,6 +1582,8 @@ namespace Nuake {
|
||||
Engine::LoadProject(project);
|
||||
|
||||
pInterface.m_CurrentProject = project;
|
||||
|
||||
Engine::GetCurrentWindow()->SetTitle("Nuake Engine - Editing " + project->Name);
|
||||
}
|
||||
|
||||
void OpenScene()
|
||||
@@ -1657,12 +1677,12 @@ namespace Nuake {
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("New scene"))
|
||||
{
|
||||
OpenScene();
|
||||
Engine::LoadScene(Scene::New());
|
||||
m_IsEntitySelected = false;
|
||||
}
|
||||
if (ImGui::MenuItem("Open scene...", "CTRL+SHIFT+O"))
|
||||
{
|
||||
Engine::LoadScene(Scene::New());
|
||||
OpenScene();
|
||||
m_IsEntitySelected = false;
|
||||
}
|
||||
if (ImGui::MenuItem("Save scene", "CTR+SHIFT+L+S"))
|
||||
|
||||
8
Editor/src/GizmoDrawer.h
Normal file
8
Editor/src/GizmoDrawer.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
class GizmoDrawer
|
||||
{
|
||||
void Draw();
|
||||
|
||||
|
||||
};
|
||||
@@ -18,7 +18,7 @@ namespace Nuake
|
||||
Ref<Window> Engine::CurrentWindow;
|
||||
|
||||
float Engine::m_LastFrameTime = 0.0f;
|
||||
float Engine::m_FixedUpdateRate = 1.0 / 144.0f;
|
||||
float Engine::m_FixedUpdateRate = 1.0f / 90.0f;
|
||||
float Engine::m_FixedUpdateDifference = 0.f;
|
||||
float Engine::m_Time = 0.f;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Nuake
|
||||
if (m_FixedUpdateDifference >= m_FixedUpdateRate) {
|
||||
CurrentWindow->FixedUpdate(m_FixedUpdateDifference);
|
||||
|
||||
m_FixedUpdateDifference -= m_FixedUpdateRate;
|
||||
m_FixedUpdateDifference = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -96,6 +96,8 @@ namespace Nuake
|
||||
|
||||
void Engine::Draw()
|
||||
{
|
||||
Nuake::RenderCommand::Clear();
|
||||
|
||||
// Start imgui frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
@@ -90,6 +90,12 @@ namespace Nuake
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FileSystem::FileExists(const std::string path)
|
||||
{
|
||||
std::ifstream f(path.c_str());
|
||||
return f.good();
|
||||
}
|
||||
|
||||
void FileSystem::SetRootDirectory(const std::string path)
|
||||
{
|
||||
Root = path;
|
||||
|
||||
@@ -129,8 +129,6 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CharacterController::UpdatePosition()
|
||||
{
|
||||
// Ray cast, ignore rigid body
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Nuake
|
||||
|
||||
void DynamicWorld::StepSimulation(Timestep ts)
|
||||
{
|
||||
dynamicsWorld->stepSimulation(ts);
|
||||
dynamicsWorld->stepSimulation(ts, 0);
|
||||
for (int j = dynamicsWorld->getNumCollisionObjects() - 1; j >= 0; j--)
|
||||
{
|
||||
btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[j];
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "VertexBuffer.h"
|
||||
|
||||
namespace Nuake {
|
||||
VertexBuffer::VertexBuffer(const void* data, unsigned int size, RendererEnum bufferType)
|
||||
VertexBuffer::VertexBuffer(const void* data, unsigned int size, RendererEnum bufferType, RendererEnum dataHint)
|
||||
{
|
||||
m_BufferType = bufferType;
|
||||
RenderCommand::GenBuffer(m_RendererID);
|
||||
Bind();
|
||||
RenderCommand::SetBufferData(m_BufferType, data, size);
|
||||
RenderCommand::SetBufferData(m_BufferType, data, size, dataHint);
|
||||
}
|
||||
|
||||
VertexBuffer::~VertexBuffer()
|
||||
@@ -14,6 +14,11 @@ namespace Nuake {
|
||||
RenderCommand::DeleteBuffer(m_RendererID);
|
||||
}
|
||||
|
||||
void VertexBuffer::SetSubData(const void* data, unsigned int size, unsigned int offset)
|
||||
{
|
||||
RenderCommand::SetBufferSubData(m_BufferType, data, size, offset);
|
||||
}
|
||||
|
||||
void VertexBuffer::Bind() const
|
||||
{
|
||||
RenderCommand::BindBuffer(m_BufferType, m_RendererID);
|
||||
|
||||
@@ -6,9 +6,11 @@ namespace Nuake {
|
||||
{
|
||||
public:
|
||||
VertexBuffer() {}
|
||||
VertexBuffer(const void* data, unsigned int size, RendererEnum bufferType = RendererEnum::ARRAY_BUFFER);
|
||||
VertexBuffer(const void* data, unsigned int size, RendererEnum bufferType = RendererEnum::ARRAY_BUFFER, RendererEnum dataHint = RendererEnum::STATIC_DRAW);
|
||||
~VertexBuffer();
|
||||
|
||||
void SetSubData(const void* data, unsigned int size, unsigned int offset = 0);
|
||||
|
||||
void Bind() const;
|
||||
void Unbind() const;
|
||||
private:
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Nuake
|
||||
//cam->cameraRight = glm::normalize(glm::cross(cam->up, cam->cameraFront));
|
||||
Direction = glm::normalize(direction);
|
||||
Right = glm::normalize(glm::cross(Vector3(0, 1, 0), Direction));
|
||||
|
||||
}
|
||||
|
||||
Vector3 Camera::GetTranslation() {
|
||||
@@ -86,6 +87,12 @@ namespace Nuake
|
||||
return m_Frustum.IsBoxVisible(aabb.Min, aabb.Max);
|
||||
}
|
||||
|
||||
Frustum Camera::GetFrustum()
|
||||
{
|
||||
m_Frustum = Frustum(GetPerspective() * GetTransform());
|
||||
return m_Frustum;
|
||||
}
|
||||
|
||||
json Camera::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Nuake
|
||||
Vector3 Translation = { 0.0f, 0.0f, 0.0f };
|
||||
float Fov = 88.0f;
|
||||
float Exposure = 1.0f;
|
||||
float Gamma = 2.2f;
|
||||
float Speed = 1.0f;
|
||||
|
||||
Camera();
|
||||
@@ -51,8 +52,9 @@ namespace Nuake
|
||||
Matrix4 GetTransform();
|
||||
Matrix4 GetTransformRotation();
|
||||
inline Vector3 GetRight() const { return Right; }
|
||||
inline Vector3 GetUp() const { return glm::cross(Direction, Right); }
|
||||
bool BoxFrustumCheck(const AABB& aabb);
|
||||
|
||||
Frustum GetFrustum();
|
||||
json Serialize() override;
|
||||
bool Deserialize(const std::string& str) override;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "src/Core/Maths.h"
|
||||
#include <glm/matrix.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nuake {
|
||||
class Frustum
|
||||
@@ -38,6 +39,16 @@ namespace Nuake {
|
||||
|
||||
Vector4 m_planes[Count];
|
||||
Vector3 m_points[8];
|
||||
|
||||
public:
|
||||
|
||||
std::vector<Vector3> GetPoints()
|
||||
{
|
||||
std::vector<Vector3> result = std::vector<Vector3>();
|
||||
for (int i = 0; i < 8; i++)
|
||||
result.push_back(m_points[i]);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
inline Frustum::Frustum(Matrix4 m)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace Nuake {
|
||||
class Material
|
||||
{
|
||||
public:
|
||||
virtual void Bind();
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "src/Rendering/Shaders/Shader.h"
|
||||
|
||||
namespace Nuake {
|
||||
class PBRMaterial
|
||||
{
|
||||
public:
|
||||
static Ref<Shader> mShader;
|
||||
|
||||
PBRMaterial();
|
||||
|
||||
void Bind();
|
||||
private:
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "src/Rendering/Buffers/VertexArray.h"
|
||||
#include "src/Rendering/Buffers/VertexBufferLayout.h"
|
||||
#include "src/Rendering/AABB.h"
|
||||
#include <src/Resource/Serializable.h>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -23,8 +24,36 @@ namespace Nuake
|
||||
|
||||
void Draw(Shader* shader, bool bindMaterial = true);
|
||||
void DebugDraw();
|
||||
|
||||
|
||||
inline AABB GetAABB() const { return m_AABB; }
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
j["Material"] = m_Material->Serialize();
|
||||
j["Indices"] = m_Indices;
|
||||
|
||||
for (unsigned int i = 0; i < m_Vertices.size(); i++)
|
||||
{
|
||||
j["Vertices"][i]["Position"] = SERIALIZE_VEC3(m_Vertices[i].position);
|
||||
j["Vertices"][i]["Normal"] = SERIALIZE_VEC3(m_Vertices[i].normal);
|
||||
j["Vertices"][i]["UV"] = SERIALIZE_VEC2(m_Vertices[i].uv);
|
||||
j["Vertices"][i]["Tangent"] = SERIALIZE_VEC3(m_Vertices[i].tangent);
|
||||
j["Vertices"][i]["Bitangent"] = SERIALIZE_VEC3(m_Vertices[i].bitangent);
|
||||
}
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Deserialize(std::string str)
|
||||
{
|
||||
BEGIN_DESERIALIZE();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
VertexBuffer* m_VertexBuffer;
|
||||
VertexArray* m_VertexArray;
|
||||
|
||||
@@ -32,9 +32,14 @@ namespace Nuake {
|
||||
glBindBuffer(GetType(bufferType), bufferID);
|
||||
}
|
||||
|
||||
void OGLRendererAPI::SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size)
|
||||
void OGLRendererAPI::SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size, const RendererEnum bufferDataHint)
|
||||
{
|
||||
glBufferData(GetType(bufferType), size, data, GL_STATIC_DRAW);
|
||||
glBufferData(GetType(bufferType), size, data, GetType(bufferDataHint));
|
||||
}
|
||||
|
||||
void OGLRendererAPI::SetBufferSubData(const RendererEnum bufferType, const void* data, unsigned int size, unsigned int offset)
|
||||
{
|
||||
glBufferSubData(GetType(bufferType), offset, size, data);
|
||||
}
|
||||
|
||||
void OGLRendererAPI::DeleteBuffer(const unsigned int& bufferID)
|
||||
@@ -83,6 +88,11 @@ namespace Nuake {
|
||||
glDrawArrays(GL_TRIANGLES, from, count);
|
||||
}
|
||||
|
||||
void OGLRendererAPI::DrawLines(int from, int count)
|
||||
{
|
||||
glDrawArrays(GL_LINES, from, count);
|
||||
}
|
||||
|
||||
GLenum OGLRendererAPI::GetType(const RendererEnum& bufferType)
|
||||
{
|
||||
switch (bufferType)
|
||||
@@ -96,8 +106,12 @@ namespace Nuake {
|
||||
case RendererEnum::INT: return GL_INT;
|
||||
case RendererEnum::UINT: return GL_UNSIGNED_INT;
|
||||
case RendererEnum::TRIANGLES: return GL_TRIANGLES;
|
||||
case RendererEnum::LINES: return GL_LINES;
|
||||
case RendererEnum::DEPTH_TEST: return GL_DEPTH_TEST;
|
||||
case RendererEnum::FACE_CULL: return GL_CULL_FACE;
|
||||
case RendererEnum::STATIC_DRAW: return GL_STATIC_DRAW;
|
||||
case RendererEnum::DYNAMIC_DRAW: return GL_DYNAMIC_DRAW;
|
||||
case RendererEnum::STREAM_DRAW: return GL_STREAM_DRAW;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace Nuake {
|
||||
|
||||
void GenBuffer(unsigned int& bufferID) override;
|
||||
void BindBuffer(const RendererEnum bufferType, const unsigned int& bufferID) override;
|
||||
void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size) override;
|
||||
void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size, const RendererEnum drawType) override;
|
||||
void SetBufferSubData(const RendererEnum bufferType, const void* data, unsigned int size, unsigned int offset = 0) override;
|
||||
void DeleteBuffer(const unsigned int& bufferID) override;
|
||||
|
||||
void GenVertexArray(unsigned int& rendererID) override;
|
||||
@@ -28,6 +29,9 @@ namespace Nuake {
|
||||
void DrawMultiElements(const RendererEnum mode, const int count, const RendererEnum type, const void* const* indices, unsigned int drawCount) override;
|
||||
void DrawElements(const RendererEnum mode, const int count, const RendererEnum type, const void* indices) override;
|
||||
void DrawArrays(int from, int count) override;
|
||||
|
||||
void DrawLines(int from, int count) override;
|
||||
|
||||
private:
|
||||
GLenum GetType(const RendererEnum& bufferType);
|
||||
};
|
||||
|
||||
@@ -7,9 +7,10 @@ namespace Nuake {
|
||||
FLOAT, UFLOAT,
|
||||
ARRAY_BUFFER,
|
||||
ELEMENT_ARRAY_BUFFER,
|
||||
TRIANGLES,
|
||||
TRIANGLES, LINES,
|
||||
DEPTH_ATTACHMENT, COLOR_ATTACHMENT0, COLOR_ATTACHMENT1,
|
||||
DEPTH_TEST, FACE_CULL
|
||||
DEPTH_TEST, FACE_CULL,
|
||||
STATIC_DRAW, DYNAMIC_DRAW, STREAM_DRAW
|
||||
};
|
||||
|
||||
class RendererAPI
|
||||
@@ -23,7 +24,8 @@ namespace Nuake {
|
||||
|
||||
virtual void GenBuffer(unsigned int& bufferID) = 0;
|
||||
virtual void BindBuffer(const RendererEnum bufferType, const unsigned int& bufferID) = 0;
|
||||
virtual void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size) = 0;
|
||||
virtual void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size, const RendererEnum bufferDataHint = RendererEnum::STATIC_DRAW) = 0;
|
||||
virtual void SetBufferSubData(const RendererEnum bufferType, const void* data, unsigned int size, unsigned int offset = 0) = 0;
|
||||
virtual void DeleteBuffer(const unsigned int& bufferID) = 0;
|
||||
|
||||
virtual void GenVertexArray(unsigned int& rendererID) = 0;
|
||||
@@ -35,5 +37,6 @@ namespace Nuake {
|
||||
virtual void DrawMultiElements(const RendererEnum mode, const int count, const RendererEnum type, const void* const* indices, unsigned int drawCount) = 0;
|
||||
virtual void DrawElements(const RendererEnum mode, const int count, const RendererEnum type, const void* indices) = 0;
|
||||
virtual void DrawArrays(int from, int count) = 0;
|
||||
virtual void DrawLines(int from, int count) = 0;
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <dependencies/GLEW/include/GL/glew.h>
|
||||
#include "src/Rendering/Renderer.h"
|
||||
#include <src/Vendors/imgui/imgui.h>
|
||||
#include "Engine.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -73,6 +74,7 @@ namespace Nuake
|
||||
|
||||
Shader* shader = ShaderManager::GetShader("resources/Shaders/bloom.shader");
|
||||
|
||||
|
||||
m_ThresholdFB->Bind();
|
||||
{
|
||||
m_ThresholdFB->Clear();
|
||||
@@ -163,7 +165,6 @@ namespace Nuake
|
||||
shader->SetUniform1i("u_Stage", 5);
|
||||
shader->SetUniform1i("u_Source", 1);
|
||||
shader->SetUniform1i("u_Source2", 2);
|
||||
|
||||
m_UpSampleFB[m_Iteration - 1]->GetTexture()->Bind(1);
|
||||
m_Source->Bind(2);
|
||||
Renderer::DrawQuad(Matrix4());
|
||||
|
||||
@@ -39,9 +39,14 @@ namespace Nuake {
|
||||
sRendererAPI->BindBuffer(bufferType, bufferID);
|
||||
}
|
||||
|
||||
void RenderCommand::SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size)
|
||||
void RenderCommand::SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size, const RendererEnum dataHint)
|
||||
{
|
||||
sRendererAPI->SetBufferData(bufferType, data, size);
|
||||
sRendererAPI->SetBufferData(bufferType, data, size, dataHint);
|
||||
}
|
||||
|
||||
void RenderCommand::SetBufferSubData(const RendererEnum bufferType, const void* data, unsigned int size, unsigned int offset)
|
||||
{
|
||||
sRendererAPI->SetBufferSubData(bufferType, data, size, offset);
|
||||
}
|
||||
|
||||
void RenderCommand::DeleteBuffer(unsigned int bufferID)
|
||||
@@ -88,4 +93,9 @@ namespace Nuake {
|
||||
{
|
||||
sRendererAPI->DrawArrays(first, count);
|
||||
}
|
||||
|
||||
void RenderCommand::DrawLines(int first, int count)
|
||||
{
|
||||
sRendererAPI->DrawLines(first, count);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@ namespace Nuake {
|
||||
static void Disable(const RendererEnum enumType);
|
||||
static void GenBuffer(unsigned int& bufferID);
|
||||
static void BindBuffer(const RendererEnum bufferType, const unsigned int& bufferID);
|
||||
static void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size);
|
||||
static void SetBufferData(const RendererEnum bufferType, const void* data, unsigned int size, const RendererEnum dataHint);
|
||||
static void SetBufferSubData(const RendererEnum bufferType, const void* data, unsigned int size, unsigned int offset = 0);
|
||||
static void DeleteBuffer(unsigned int bufferID);
|
||||
|
||||
static void GenVertexArray(unsigned int& rendererID);
|
||||
@@ -31,6 +32,9 @@ namespace Nuake {
|
||||
static void DrawMultiElements(const RendererEnum mode, const int count, const RendererEnum type, const void* const* indices, unsigned int drawCount);
|
||||
static void DrawElements(const RendererEnum mode, const int count, const RendererEnum type, const void* indices);
|
||||
static void DrawArrays(int first, int count);
|
||||
|
||||
static void DrawLines(int first, int count);
|
||||
|
||||
private:
|
||||
static RendererAPI* sRendererAPI;
|
||||
};
|
||||
|
||||
@@ -13,12 +13,16 @@
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include "Buffers/VertexBufferLayout.h"
|
||||
#include "src/Rendering/Textures/MaterialManager.h"
|
||||
#include "src/Rendering/Vertex.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
unsigned int depthTexture;
|
||||
unsigned int depthFBO;
|
||||
|
||||
Ref<Mesh> Renderer::CubeMesh;
|
||||
|
||||
Shader* Renderer::m_Shader;
|
||||
Shader* Renderer::m_SkyboxShader;
|
||||
Shader* Renderer::m_BRDShader;
|
||||
@@ -36,19 +40,26 @@ namespace Nuake
|
||||
Ref<UniformBuffer> Renderer::m_LightsUniformBuffer;
|
||||
RenderList Renderer::m_RenderList = RenderList();
|
||||
|
||||
glm::vec3 CubeVertices[36] {
|
||||
glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(0.5f, -0.5f, -0.5f), glm::vec3(0.5f, 0.5f, -0.5f),
|
||||
glm::vec3(0.5f, 0.5f, -0.5f), glm::vec3(-0.5f, 0.5f, -0.5f), glm::vec3(-0.5f, -0.5f, -0.5f),
|
||||
glm::vec3(-0.5f, -0.5f, 0.5f), glm::vec3(0.5f, -0.5f, 0.5f), glm::vec3(0.5f, 0.5f, 0.5f),
|
||||
glm::vec3(0.5f, 0.5f, 0.5f), glm::vec3(-0.5f, 0.5f, 0.5f), glm::vec3(-0.5f, -0.5f, 0.5f),
|
||||
glm::vec3(-0.5f, 0.5f, 0.5f), glm::vec3(-0.5f, 0.5f, -0.5f), glm::vec3(-0.5f, -0.5f, -0.5f),
|
||||
glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(-0.5f, -0.5f, 0.5f), glm::vec3(-0.5f, 0.5f, 0.5f),
|
||||
glm::vec3(0.5f, 0.5f, 0.5f), glm::vec3(0.5f, 0.5f, -0.5f), glm::vec3(0.5f, -0.5f, -0.5f),
|
||||
glm::vec3(0.5f, -0.5f, -0.5f), glm::vec3(0.5f, -0.5f, 0.5f), glm::vec3(0.5f, 0.5f, 0.5f),
|
||||
glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec3(0.5f, -0.5f, -0.5f), glm::vec3(0.5f, -0.5f, 0.5f),
|
||||
glm::vec3(0.5f, -0.5f, 0.5f), glm::vec3(-0.5f, -0.5f, 0.5f), glm::vec3(-0.5f, -0.5f, -0.5f),
|
||||
glm::vec3(-0.5f, 0.5f, -0.5f), glm::vec3(0.5f, 0.5f, -0.5f), glm::vec3(0.5f, 0.5f, 0.5f),
|
||||
glm::vec3(0.5f, 0.5f, 0.5f), glm::vec3(-0.5f, 0.5f, 0.5f), glm::vec3(-0.5f, 0.5f, -0.5f)
|
||||
std::vector<Vertex> CubeVertices
|
||||
{
|
||||
{Vector3(-0.5f, -0.5f, -0.5f), Vector2(0, 0), Vector3(-1, 0, 0)},
|
||||
{Vector3( 0.5f, -0.5f, -0.5f), Vector2(1, 0), Vector3(-1, -1, 0)},
|
||||
{Vector3( 0.5f, 0.5f, -0.5f), Vector2(0, 1), Vector3(-1, 0, 0)},
|
||||
{Vector3(-0.5f, 0.5f, -0.5f), Vector2(1, 1), Vector3(-1, 0, 0)},
|
||||
{Vector3(-0.5f, -0.5f, 0.5f), Vector2(0, 1), Vector3(-1, 0, 0)},
|
||||
{Vector3( 0.5f, -0.5f, 0.5f), Vector2(1, 0), Vector3(-1, 0, 0)},
|
||||
{Vector3( 0.5f, 0.5f, 0.5f), Vector2(1, 1), Vector3(-1, 0, 0)},
|
||||
{Vector3(-0.5f, 0.5f, 0.5f), Vector2(1, 1), Vector3(-1, 0, 0)}
|
||||
};
|
||||
|
||||
std::vector<unsigned int> CubeIndices
|
||||
{
|
||||
0, 1, 3, 3, 1, 2,
|
||||
1, 5, 2, 2, 5, 6,
|
||||
5, 4, 6, 6, 4, 7,
|
||||
4, 0, 7, 7, 0, 3,
|
||||
3, 2, 7, 7, 2, 6,
|
||||
4, 5, 0, 0, 5, 1
|
||||
};
|
||||
|
||||
float QuadVertices[] = {
|
||||
@@ -69,14 +80,18 @@ namespace Nuake
|
||||
|
||||
m_LightsUniformBuffer = CreateRef<UniformBuffer>(128);
|
||||
|
||||
// Cube buffer
|
||||
CubeVertexArray = new VertexArray();
|
||||
CubeVertexArray->Bind();
|
||||
CubeVertexBuffer = new VertexBuffer(CubeVertices, sizeof(CubeVertices));
|
||||
Ref<Material> material = MaterialManager::Get()->GetMaterial("default");
|
||||
|
||||
CubeMesh = CreateRef<Mesh>(CubeVertices, CubeIndices, material);
|
||||
|
||||
// Cube buffer
|
||||
//CubeVertexArray = new VertexArray();
|
||||
//CubeVertexArray->Bind();
|
||||
//CubeVertexBuffer = new VertexBuffer(CubeVertices, sizeof(CubeVertices));
|
||||
//
|
||||
VertexBufferLayout vblayout = VertexBufferLayout();
|
||||
vblayout.Push<float>(3);
|
||||
CubeVertexArray->AddBuffer(*CubeVertexBuffer, vblayout);
|
||||
//CubeVertexArray->AddBuffer(*CubeVertexBuffer, vblayout);
|
||||
|
||||
// Quad buffer
|
||||
QuadVertexArray = new VertexArray();
|
||||
@@ -98,6 +113,11 @@ namespace Nuake
|
||||
m_RenderList.AddToRenderList(mesh, transform);
|
||||
}
|
||||
|
||||
void Renderer::SubmitCube(Matrix4 transform)
|
||||
{
|
||||
m_RenderList.AddToRenderList(CubeMesh, transform);
|
||||
}
|
||||
|
||||
void Renderer::Flush(Shader* shader, bool depthOnly)
|
||||
{
|
||||
m_RenderList.Flush(shader, depthOnly);
|
||||
@@ -105,6 +125,11 @@ namespace Nuake
|
||||
|
||||
void Renderer::BeginDraw(Ref<Camera> camera)
|
||||
{
|
||||
Shader* lineShader = ShaderManager::GetShader("resources/Shaders/line.shader");
|
||||
lineShader->Bind();
|
||||
lineShader->SetUniformMat4f("u_Projection", camera->GetPerspective());
|
||||
lineShader->SetUniformMat4f("u_View", camera->GetTransform());
|
||||
|
||||
m_Shader->Bind();
|
||||
m_Shader->SetUniformMat4f("u_Projection", camera->GetPerspective());
|
||||
m_Shader->SetUniformMat4f("u_View", camera->GetTransform());
|
||||
@@ -132,7 +157,6 @@ namespace Nuake
|
||||
|
||||
Vector3 direction = light.GetDirection();
|
||||
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);
|
||||
|
||||
@@ -161,6 +185,30 @@ namespace Nuake
|
||||
//m_LightsUniformBuffer->UpdateData()
|
||||
}
|
||||
|
||||
void Renderer::DrawLine(Vector3 start, Vector3 end, Color color, Matrix4 transform)
|
||||
{
|
||||
Shader* shader = ShaderManager::GetShader("resources/Shaders/line.shader");
|
||||
shader->Bind();
|
||||
shader->SetUniformMat4f("u_Model", transform);
|
||||
shader->SetUniform4f("u_Color", color.r, color.g, color.b, color.a);
|
||||
|
||||
std::vector<Vertex> vertices
|
||||
{
|
||||
{start, Vector2(0, 0), Vector3(-1, 0, 0)},
|
||||
{end, Vector2(1, 0), Vector3(-1, -1, 0)}
|
||||
};
|
||||
|
||||
VertexArray lineVertexArray = VertexArray();
|
||||
lineVertexArray.Bind();
|
||||
VertexBuffer lineVertexBuffer = VertexBuffer(&vertices, size(vertices));
|
||||
|
||||
VertexBufferLayout vblayout = VertexBufferLayout();
|
||||
vblayout.Push<float>(3);
|
||||
lineVertexArray.AddBuffer(lineVertexBuffer, vblayout);
|
||||
|
||||
RenderCommand::DrawLines(0, 2);
|
||||
}
|
||||
|
||||
void Renderer::DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color)
|
||||
{
|
||||
//m_DebugShader->Bind();
|
||||
|
||||
@@ -54,11 +54,14 @@ namespace Nuake
|
||||
|
||||
static Ref<UniformBuffer> m_LightsUniformBuffer;
|
||||
|
||||
static Ref<Mesh> CubeMesh;
|
||||
|
||||
static void Init();
|
||||
static void LoadShaders();
|
||||
|
||||
static void BeginScene();
|
||||
static void SubmitMesh(Ref<Mesh> mesh, Matrix4 transform);
|
||||
static void SubmitCube(Matrix4 transform);
|
||||
static void Flush(Shader* shader, bool depthOnly = false);
|
||||
|
||||
// Drawing states
|
||||
@@ -73,6 +76,7 @@ namespace Nuake
|
||||
|
||||
|
||||
// Debug
|
||||
static void DrawLine(Vector3 start, Vector3 end, Color color, Matrix4 transform = Matrix4());
|
||||
static void DrawDebugLine(glm::vec3 start, glm::vec3 end, glm::vec4 color);
|
||||
static void DrawCube(TransformComponent transform, glm::vec4 color);
|
||||
static void DrawSphere(TransformComponent transform, glm::vec4 color);
|
||||
|
||||
@@ -45,9 +45,15 @@ namespace Nuake {
|
||||
mShadingBuffer->QueueResize(framebuffer.GetSize());
|
||||
ShadingPass(scene);
|
||||
|
||||
scene.GetEnvironment()->mBloom->SetSource(mShadingBuffer->GetTexture());
|
||||
scene.GetEnvironment()->mBloom->Resize(framebuffer.GetSize());
|
||||
scene.GetEnvironment()->mBloom->Draw();
|
||||
Texture* finalOutput = mShadingBuffer->GetTexture().get();
|
||||
if (scene.GetEnvironment()->BloomEnabled)
|
||||
{
|
||||
scene.GetEnvironment()->mBloom->SetSource(mShadingBuffer->GetTexture());
|
||||
scene.GetEnvironment()->mBloom->Resize(framebuffer.GetSize());
|
||||
scene.GetEnvironment()->mBloom->Draw();
|
||||
|
||||
finalOutput = scene.GetEnvironment()->mBloom->GetOutput().get();
|
||||
}
|
||||
|
||||
auto view = scene.m_Registry.view<LightComponent>();
|
||||
std::vector<LightComponent> lightList = std::vector<LightComponent>();
|
||||
@@ -57,18 +63,26 @@ namespace Nuake {
|
||||
if (lc.Type == Directional && lc.IsVolumetric)
|
||||
lightList.push_back(lc);
|
||||
}
|
||||
|
||||
|
||||
if (scene.GetEnvironment()->VolumetricEnabled)
|
||||
{
|
||||
mVolumetric->Resize(framebuffer.GetSize());
|
||||
mVolumetric->SetDepth(mGBuffer->GetTexture(GL_DEPTH_ATTACHMENT).get());
|
||||
mVolumetric->Draw(mProjection, mView, lightList);
|
||||
|
||||
mVolumetric->Resize(framebuffer.GetSize());
|
||||
mVolumetric->SetDepth(mGBuffer->GetTexture(GL_DEPTH_ATTACHMENT).get());
|
||||
mVolumetric->Draw(mProjection, mView, lightList);
|
||||
finalOutput = mVolumetric->GetFinalOutput();
|
||||
}
|
||||
|
||||
|
||||
// Copy final output to target framebuffer
|
||||
framebuffer.Bind();
|
||||
{
|
||||
Shader* shader = ShaderManager::GetShader("resources/Shaders/copy.shader");
|
||||
Shader* shader = ShaderManager::GetShader("resources/Shaders/tonemap.shader");
|
||||
shader->Bind();
|
||||
shader->SetUniformTex("u_Source", scene.GetEnvironment()->mBloom->GetOutput().get());
|
||||
|
||||
shader->SetUniform1f("u_Exposure", scene.GetEnvironment()->Exposure);
|
||||
shader->SetUniform1f("u_Gamma", scene.GetEnvironment()->Gamma);
|
||||
shader->SetUniformTex("u_Source", finalOutput);
|
||||
Renderer::DrawQuad();
|
||||
}
|
||||
framebuffer.Unbind();
|
||||
@@ -184,7 +198,7 @@ namespace Nuake {
|
||||
shadingShader->Bind();
|
||||
shadingShader->SetUniformMat4f("u_Projection", mProjection);
|
||||
shadingShader->SetUniformMat4f("u_View", mView);
|
||||
shadingShader->SetUniformVec3("u_EyePosition", mView[3]);
|
||||
shadingShader->SetUniformVec3("u_EyePosition", scene.GetCurrentCamera()->Translation);
|
||||
|
||||
Ref<Environment> env = scene.GetEnvironment();
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Nuake
|
||||
m_Shaders[path] = CreateScope<Shader>(path);
|
||||
}
|
||||
|
||||
|
||||
return m_Shaders[path].get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Nuake
|
||||
|
||||
Material::Material(const std::string albedo)
|
||||
{
|
||||
InitUniformBuffer();
|
||||
|
||||
glGenBuffers(1, &UBO);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(UBOStructure), NULL, GL_STATIC_DRAW);
|
||||
@@ -56,6 +58,8 @@ namespace Nuake
|
||||
|
||||
Material::Material(const glm::vec3 albedoColor)
|
||||
{
|
||||
InitUniformBuffer();
|
||||
|
||||
glGenBuffers(1, &UBO);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
||||
glBufferData(GL_UNIFORM_BUFFER, 128, NULL, GL_STATIC_DRAW);
|
||||
@@ -142,6 +146,7 @@ namespace Nuake
|
||||
|
||||
void Material::SetupUniformBuffer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Material::SetName(const std::string name)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "src/Rendering/Shaders/Shader.h"
|
||||
#include "src/Rendering/Textures/TextureManager.h"
|
||||
#include "Texture.h"
|
||||
#include <src/Resource/Serializable.h>
|
||||
|
||||
|
||||
namespace Nuake
|
||||
@@ -26,11 +27,31 @@ namespace Nuake
|
||||
int u_Unlit;
|
||||
};
|
||||
|
||||
class Material
|
||||
class Material : ISerializable
|
||||
{
|
||||
private:
|
||||
std::string m_Name;
|
||||
unsigned int UBO;
|
||||
|
||||
void InitUniformBuffer()
|
||||
{
|
||||
data = {
|
||||
0, // Has albedo texture
|
||||
0, // Padding byte
|
||||
0, // Padding byte
|
||||
0, // Padding byte
|
||||
Vector3(1.f, 1.f, 1.f), // Albedo color
|
||||
0, // Has metalness
|
||||
0.f, // Metalness value
|
||||
0, // u_HasRoughness
|
||||
1.f, // u_RoughnessValue
|
||||
0, // u_HasAO
|
||||
0.5f, // u_AOValue
|
||||
0, // u_HasNormal
|
||||
0, // u_HasDisplacement
|
||||
0
|
||||
};
|
||||
}
|
||||
public:
|
||||
Ref<Texture> m_Albedo;
|
||||
Ref<Texture> m_AO;
|
||||
@@ -39,23 +60,7 @@ namespace Nuake
|
||||
Ref<Texture> m_Normal;
|
||||
Ref<Texture> m_Displacement;
|
||||
|
||||
UBOStructure data
|
||||
{
|
||||
0, // Has albedo texture
|
||||
0, // Padding byte
|
||||
0, // Padding byte
|
||||
0, // Padding byte
|
||||
Vector3(0.f, 0.f, 0.f), // Albedo color
|
||||
0, // Has metalness
|
||||
0.f, // Metalness value
|
||||
0, // u_HasRoughness
|
||||
1.f, // u_RoughnessValue
|
||||
0, // u_HasAO
|
||||
1.f, // u_AOValue
|
||||
0, // u_HasNormal
|
||||
0, // u_HasDisplacement
|
||||
0
|
||||
};
|
||||
UBOStructure data;
|
||||
|
||||
static Ref<Texture> m_DefaultAlbedo;
|
||||
static Ref<Texture> m_DefaultAO;
|
||||
@@ -64,20 +69,19 @@ namespace Nuake
|
||||
static Ref<Texture> m_DefaultNormal;
|
||||
static Ref<Texture> m_DefaultDisplacement;
|
||||
|
||||
Material();
|
||||
Material(const std::string albedo);
|
||||
Material(Ref<Texture> texture) { m_Albedo = texture; }
|
||||
Material(const glm::vec3 albedoColor);
|
||||
|
||||
~Material();
|
||||
|
||||
void Bind(Shader* shader);
|
||||
|
||||
void SetupUniformBuffer();
|
||||
|
||||
void SetName(const std::string name);
|
||||
std::string GetName();
|
||||
|
||||
inline void SetUnlit(bool value) {data.u_Unlit = value; }
|
||||
inline void SetUnlit(bool value) { data.u_Unlit = value; }
|
||||
inline bool GetUnlit() { return data.u_Unlit == 1; }
|
||||
|
||||
bool HasAlbedo() { return m_Albedo != nullptr; }
|
||||
@@ -92,7 +96,7 @@ namespace Nuake
|
||||
void SetMetalness(const std::string albedo);
|
||||
void SetMetalness(Ref<Texture> texture) { m_Metalness = texture; }
|
||||
|
||||
bool HasRougness() { return m_Roughness != nullptr; }
|
||||
bool HasRoughness() { return m_Roughness != nullptr; }
|
||||
void SetRoughness(const std::string albedo);
|
||||
void SetRoughness(Ref<Texture> texture) { m_Roughness = texture; }
|
||||
|
||||
@@ -103,5 +107,28 @@ namespace Nuake
|
||||
bool HasDisplacement() { return m_Displacement != nullptr; }
|
||||
void SetDisplacement(const std::string displacement);
|
||||
void SetDisplacement(Ref<Texture> texture) { m_Displacement = texture; }
|
||||
|
||||
json Serialize() override
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
j["Path"] = this->m_Name;
|
||||
j["HasAlbedo"] = this->HasAlbedo();
|
||||
if (HasAlbedo())
|
||||
{
|
||||
j["Abledo"] = this->m_Albedo->Serialize();
|
||||
}
|
||||
j["HasAO"] = this->HasAO();
|
||||
j["HasMetalness"] = this->HasMetalness();
|
||||
j["HasRoughness"] = this->HasRoughness();
|
||||
j["HasNormal"] = this->HasNormal();
|
||||
j["HasDisplacement"] = this->HasDisplacement();
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Deserialize(const std::string& str) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "json/json.hpp"
|
||||
|
||||
#include "../Rendering/Textures/Material.h"
|
||||
#include "src/Core/FileSystem.h"
|
||||
#include "src/Core/Logger.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -17,16 +19,25 @@ namespace Nuake
|
||||
MaterialManager::MaterialManager()
|
||||
{
|
||||
m_Materials = std::map<std::string, Ref<Material>>();
|
||||
|
||||
GetMaterial(DEFAULT_MATERIAL);
|
||||
}
|
||||
|
||||
Ref<Material> MaterialManager::GetMaterial(const std::string name)
|
||||
Ref<Material> MaterialManager::GetMaterial(std::string name)
|
||||
{
|
||||
if (!FileSystem::FileExists(name))
|
||||
{
|
||||
Logger::Log("Couldn't load material: " + name + " - File doesn't exists", Nuake::LOG_TYPE::CRITICAL);
|
||||
name = DEFAULT_MATERIAL;
|
||||
}
|
||||
|
||||
if (!IsMaterialLoaded(name))
|
||||
{
|
||||
Ref<Material> newMaterial = CreateRef<Material>(name);
|
||||
RegisterMaterial(newMaterial);
|
||||
return newMaterial;
|
||||
}
|
||||
|
||||
return m_Materials[name];
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Nuake
|
||||
class MaterialManager
|
||||
{
|
||||
private:
|
||||
const std::string DEFAULT_MATERIAL = "resources/Textures/default/Default.png";
|
||||
|
||||
static Ref<MaterialManager> s_Instance;
|
||||
|
||||
std::map<std::string, Ref<Material>> m_Materials;
|
||||
@@ -27,9 +29,10 @@ namespace Nuake
|
||||
|
||||
void LoadMaterials();
|
||||
|
||||
|
||||
void RegisterMaterial(Ref<Material> material);
|
||||
|
||||
Ref<Material> LoadMaterial(const std::string path);
|
||||
Ref<Material> LoadMaterial(std::string path);
|
||||
|
||||
Ref<Material> GetMaterial(const std::string name);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Texture.h"
|
||||
#include "src/Core/Logger.h"
|
||||
#include <GL\glew.h>
|
||||
#include <iostream>
|
||||
#include <src/Core/FileSystem.h>
|
||||
@@ -15,7 +16,6 @@ namespace Nuake
|
||||
m_BPP = 0;
|
||||
|
||||
stbi_set_flip_vertically_on_load(1);
|
||||
|
||||
m_LocalBuffer = stbi_load((path).c_str(), &m_Width, &m_Height, &m_BPP, 4);
|
||||
|
||||
glGenTextures(1, &m_RendererId);
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include <string>
|
||||
#include "src/Core/Maths.h"
|
||||
#include "msdfgen/core/BitmapRef.hpp"
|
||||
#include "src/Resource/Serializable.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
typedef unsigned int GLenum;
|
||||
|
||||
class Texture
|
||||
class Texture : ISerializable
|
||||
{
|
||||
private:
|
||||
unsigned int m_RendererId;
|
||||
@@ -43,5 +44,21 @@ namespace Nuake
|
||||
inline int GetWidth() const { return m_Width; }
|
||||
inline int GetHeight() const { return m_Height; }
|
||||
inline Vector2 GetSize() const { return Vector2(m_Width, m_Height); }
|
||||
|
||||
json Serialize() override
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
j["Path"] = this->m_FilePath;
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Deserialize(const std::string& str) override
|
||||
{
|
||||
BEGIN_DESERIALIZE();
|
||||
if (j.contains("Path"))
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,5 +12,11 @@ namespace Nuake
|
||||
Vector3 bitangent;
|
||||
float texture;
|
||||
};
|
||||
|
||||
struct LineVertex
|
||||
{
|
||||
Vector3 position;
|
||||
Vector4 color;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,13 @@ using json = nlohmann::json;
|
||||
#define BEGIN_SERIALIZE() json j;
|
||||
#define SERIALIZE_VAL_LBL(lbl, v) j[lbl] = v;
|
||||
#define SERIALIZE_VAL(v) j[#v] = this->v;
|
||||
#define SERIALIZE_VEC3(v) \
|
||||
|
||||
#define SERIALIZE_VEC2(v) \
|
||||
j[#v]["x"] = this->v.x; \
|
||||
j[#v]["y"] = this->v.y; \
|
||||
j[#v]["y"] = this->v.y;
|
||||
|
||||
#define SERIALIZE_VEC3(v) \
|
||||
SERIALIZE_VEC2(v) \
|
||||
j[#v]["z"] = this->v.z;
|
||||
|
||||
#define SERIALIZE_VEC4(v) \
|
||||
@@ -26,7 +30,6 @@ using json = nlohmann::json;
|
||||
if(j.contains(#c)) \
|
||||
AddComponent<c>().Deserialize(j[#c].dump());
|
||||
|
||||
|
||||
class ISerializable
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "src/Core/Physics/Rigibody.h"
|
||||
|
||||
namespace Nuake {
|
||||
class BSPBrushComponent
|
||||
class BSPBrushComponent
|
||||
{
|
||||
public:
|
||||
std::vector<Ref<Mesh>> Meshes;
|
||||
@@ -22,10 +22,28 @@ namespace Nuake {
|
||||
bool IsTransparent = false;
|
||||
bool IsFunc = false;
|
||||
|
||||
BSPBrushComponent() {
|
||||
BSPBrushComponent()
|
||||
{
|
||||
Meshes = std::vector<Ref<Mesh>>();
|
||||
Materials = std::vector<Ref<Material>>();
|
||||
Rigidbody = std::vector<Ref<Physics::RigidBody>>();
|
||||
}
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
for (unsigned int i = 0; i < Meshes.size(); i++)
|
||||
{
|
||||
j["Meshes"][i] = Meshes[i]->Serialize();
|
||||
}
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool Deserialize()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
22
Nuake/src/Scene/Components/BoxCollider.cpp
Normal file
22
Nuake/src/Scene/Components/BoxCollider.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "BoxCollider.h"
|
||||
#include "src/Resource/Serializable.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
json BoxColliderComponent::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
|
||||
j["IsTrigger"] = IsTrigger;
|
||||
SERIALIZE_VEC3(Size);
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
bool BoxColliderComponent::Deserialize(const std::string& str)
|
||||
{
|
||||
BEGIN_DESERIALIZE();
|
||||
this->IsTrigger = j["IsTrigger"];
|
||||
this->Size = Vector3(j["Size"]["x"], j["Size"]["y"], j["Size"]["z"]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
#pragma once
|
||||
#include "src/Core/Physics/PhysicsShapes.h"
|
||||
#include "src/Core/Core.h"
|
||||
|
||||
namespace Nuake {
|
||||
class BoxColliderComponent
|
||||
{
|
||||
public:
|
||||
Ref<Physics::PhysicShape> Box;
|
||||
glm::vec3 Size = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
bool IsTrigger;
|
||||
bool IsTrigger = false;
|
||||
|
||||
json Serialize();
|
||||
bool Deserialize(const std::string& str);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Nuake {
|
||||
//start = glm::rotate(start, glm::radians(Direction.z), glm::vec3(0, 0, 1));
|
||||
|
||||
//return glm::vec3(start * glm::vec4(defaultDirection, 1.0f));
|
||||
return Direction;
|
||||
return glm::normalize(Direction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -108,7 +108,8 @@ namespace Nuake {
|
||||
return nullptr;
|
||||
|
||||
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
|
||||
Ref<Material> newMaterial = MaterialManager::Get()->GetMaterial(directory + std::to_string(mesh->mMaterialIndex) + material->GetName().C_Str());
|
||||
std::string materialPath = directory + std::to_string(mesh->mMaterialIndex) + material->GetName().C_Str();
|
||||
Ref<Material> newMaterial = MaterialManager::Get()->GetMaterial(materialPath);
|
||||
|
||||
aiString str;
|
||||
|
||||
@@ -126,7 +127,13 @@ namespace Nuake {
|
||||
}
|
||||
else
|
||||
{
|
||||
newMaterial->SetAlbedo(TextureManager::Get()->GetTexture(FileSystem::Root + directory + str.C_Str()));
|
||||
std::string texturePath = FileSystem::Root + directory + str.C_Str();
|
||||
if (!FileSystem::FileExists(texturePath))
|
||||
{
|
||||
Logger::Log("Texture file couldn't be found: " + texturePath, Nuake::LOG_TYPE::CRITICAL);
|
||||
texturePath = "resources/Textures/default/Default.png";
|
||||
}
|
||||
newMaterial->SetAlbedo(TextureManager::Get()->GetTexture(texturePath));
|
||||
}
|
||||
|
||||
material->GetTexture(aiTextureType_NORMALS, 0, &str);
|
||||
|
||||
@@ -26,6 +26,12 @@ namespace Nuake {
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VAL(HasCollisions);
|
||||
SERIALIZE_VAL(Path);
|
||||
|
||||
for (unsigned int i = 0; i < m_Meshes.size(); i++)
|
||||
{
|
||||
j["Meshes"][i] = m_Meshes[i]->Serialize();
|
||||
}
|
||||
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
@@ -34,7 +40,6 @@ namespace Nuake {
|
||||
BEGIN_DESERIALIZE();
|
||||
this->Path = j["Path"];
|
||||
this->HasCollisions = j["HasCollisions"];
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,8 +8,13 @@
|
||||
#include "../Components/QuakeMap.h"
|
||||
#include "../Components/WrenScriptComponent.h"
|
||||
#include "../Components/CharacterControllerComponent.h"
|
||||
|
||||
#include <src/Scene/Components/BoxCollider.h>
|
||||
#include <src/Scene/Components/MeshComponent.h>
|
||||
|
||||
//#include <src/Scene/Components/BoxCollider.h>
|
||||
#include "src/Scene/Components/BSPBrushComponent.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
void Entity::AddChild(Entity ent)
|
||||
@@ -39,8 +44,13 @@ namespace Nuake
|
||||
SERIALIZE_OBJECT_REF_LBL("WrenScriptComponent", GetComponent<WrenScriptComponent>());
|
||||
if (HasComponent<CharacterControllerComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("CharacterControllerComponent", GetComponent<CharacterControllerComponent>());
|
||||
|
||||
if (HasComponent<BoxColliderComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("BoxColliderComponent", GetComponent<BoxColliderComponent>());
|
||||
if (HasComponent<MeshComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("MeshComponent", GetComponent<MeshComponent>());
|
||||
if (HasComponent<BSPBrushComponent>())
|
||||
SERIALIZE_OBJECT_REF_LBL("BSPBrushComponent", GetComponent<BSPBrushComponent>());
|
||||
END_SERIALIZE();
|
||||
}
|
||||
|
||||
@@ -56,6 +66,8 @@ namespace Nuake
|
||||
DESERIALIZE_COMPONENT(MeshComponent);
|
||||
DESERIALIZE_COMPONENT(WrenScriptComponent);
|
||||
DESERIALIZE_COMPONENT(CharacterControllerComponent);
|
||||
//DESERIALIZE_COMPONENT(BSPBrushComponent);
|
||||
DESERIALIZE_COMPONENT(BoxColliderComponent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,15 @@ namespace Nuake
|
||||
{
|
||||
public:
|
||||
Environment();
|
||||
bool VolumetricEnabled = false;
|
||||
float VolumetricFog = 0.90f;
|
||||
float VolumetricStepCount = 50.f;
|
||||
|
||||
Scope<Bloom> mBloom;
|
||||
float Exposure = 3.5f;
|
||||
float Gamma = 1.1f;
|
||||
|
||||
bool BloomEnabled = false;
|
||||
Scope<Bloom> mBloom;
|
||||
Vector3 ClearColor;
|
||||
|
||||
glm::vec4 AmbientColor;
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace Nuake {
|
||||
mSceneRenderer->Init();
|
||||
}
|
||||
|
||||
Scene::~Scene() {
|
||||
Scene::~Scene()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Scene::GetName()
|
||||
@@ -251,6 +252,15 @@ namespace Nuake {
|
||||
return true;
|
||||
}
|
||||
|
||||
Scene* Scene::Copy()
|
||||
{
|
||||
Scene* sceneCopy = new Scene();
|
||||
sceneCopy->Path = this->Path;
|
||||
sceneCopy->Name = this->Name;
|
||||
|
||||
return sceneCopy;
|
||||
}
|
||||
|
||||
json Scene::Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
@@ -285,28 +295,26 @@ namespace Nuake {
|
||||
}
|
||||
|
||||
// Parse entities
|
||||
if (!j.contains("Entities"))
|
||||
return 0;
|
||||
|
||||
for (json e : j["Entities"])
|
||||
{
|
||||
if (j.contains("Entities"))
|
||||
{
|
||||
for (json e : j["Entities"])
|
||||
{
|
||||
std::string name = e["NameComponent"]["Name"];
|
||||
Entity ent = { m_Registry.create(), this };
|
||||
ent.Deserialize(e.dump());
|
||||
}
|
||||
std::string name = e["NameComponent"]["Name"];
|
||||
Entity ent = { m_Registry.create(), this };
|
||||
ent.Deserialize(e.dump());
|
||||
}
|
||||
|
||||
auto view = m_Registry.view<ParentComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
auto parentC = view.get<ParentComponent>(e);
|
||||
if (!parentC.HasParent)
|
||||
continue;
|
||||
auto view = m_Registry.view<ParentComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
auto& parentComponent = view.get<ParentComponent>(e);
|
||||
if (!parentComponent.HasParent)
|
||||
continue;
|
||||
|
||||
auto& p = Entity{ e, this };
|
||||
auto parent = GetEntityByID(parentC.ParentID);
|
||||
parent.AddChild(p);
|
||||
}
|
||||
}
|
||||
auto& entity = Entity{ e, this };
|
||||
auto parentEntity = GetEntityByID(parentComponent.ParentID);
|
||||
parentEntity.AddChild(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -69,6 +69,8 @@ namespace Nuake {
|
||||
void AddInterface(Ref<UI::UserInterface> interface);
|
||||
|
||||
json Serialize() override;
|
||||
|
||||
Scene* Copy();
|
||||
bool Deserialize(const std::string& str) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Nuake
|
||||
|
||||
rigidbody.m_Rigidbody = btRigidbody;
|
||||
|
||||
btRigidbody->SetKinematic(rigidbody.IsKinematic);
|
||||
//btRigidbody->SetKinematic(rigidbody.IsKinematic);
|
||||
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
@@ -61,16 +61,16 @@ namespace Nuake
|
||||
{
|
||||
auto [transform, brush] = bspView.get<TransformComponent, BSPBrushComponent>(e);
|
||||
|
||||
if (brush.IsSolid)
|
||||
if (!brush.IsSolid)
|
||||
continue;
|
||||
|
||||
for (auto m : brush.Meshes)
|
||||
{
|
||||
for (auto m : brush.Meshes)
|
||||
{
|
||||
Ref<Physics::MeshShape> meshShape = CreateRef<Physics::MeshShape>(m);
|
||||
Ref<Physics::RigidBody> btRigidbody = CreateRef<Physics::RigidBody>(0.0f, transform.GlobalTranslation, meshShape);
|
||||
btRigidbody->SetEntityID(Entity{ e, m_Scene });
|
||||
brush.Rigidbody.push_back(btRigidbody);
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
Ref<Physics::MeshShape> meshShape = CreateRef<Physics::MeshShape>(m);
|
||||
Ref<Physics::RigidBody> btRigidbody = CreateRef<Physics::RigidBody>(0.0f, transform.GlobalTranslation, meshShape);
|
||||
btRigidbody->SetEntityID(Entity{ e, m_Scene });
|
||||
brush.Rigidbody.push_back(btRigidbody);
|
||||
PhysicsManager::Get()->RegisterBody(btRigidbody);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +93,6 @@ namespace Nuake
|
||||
if (!Engine::IsPlayMode)
|
||||
return;
|
||||
|
||||
PhysicsManager::Get()->Step(ts);
|
||||
|
||||
auto brushes = m_Scene->m_Registry.view<TransformComponent, BSPBrushComponent>();
|
||||
for (auto e : brushes)
|
||||
{
|
||||
@@ -122,7 +120,6 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto bspTriggerView = m_Scene->m_Registry.view<TransformComponent, BSPBrushComponent, TriggerZone>();
|
||||
for (auto e : bspTriggerView)
|
||||
{
|
||||
@@ -156,7 +153,10 @@ namespace Nuake
|
||||
|
||||
void PhysicsSystem::FixedUpdate(Timestep ts)
|
||||
{
|
||||
|
||||
if (!Engine::IsPlayMode)
|
||||
return;
|
||||
|
||||
PhysicsManager::Get()->Step(ts);
|
||||
}
|
||||
|
||||
void PhysicsSystem::Exit()
|
||||
|
||||
@@ -218,7 +218,44 @@ void generate_brush_vertices(int entity_idx, int brush_idx)
|
||||
face *face_inst = &entities[entity_idx].brushes[brush_idx].faces[f0];
|
||||
face_geometry *face_geo_inst = &entity_geo[entity_idx].brushes[brush_idx].faces[f0];
|
||||
|
||||
vec3 normal = face_inst->plane_normal;
|
||||
vec3 normal;
|
||||
|
||||
const char* phong_property = map_data_get_entity_property(entity_idx, "_phong");
|
||||
bool phong = phong_property != NULL && strcmp(phong_property, "1") == 0;
|
||||
|
||||
if (phong)
|
||||
{
|
||||
const char* phong_angle_property = map_data_get_entity_property(entity_idx, "_phong_angle");
|
||||
if (phong_angle_property != NULL)
|
||||
{
|
||||
double threshold = cos((atof(phong_angle_property) + 0.01) * 0.0174533);
|
||||
normal = brush_inst->faces[f0].plane_normal;
|
||||
if (vec3_dot(brush_inst->faces[f0].plane_normal, brush_inst->faces[f1].plane_normal) > threshold)
|
||||
{
|
||||
normal = vec3_add(normal, brush_inst->faces[f1].plane_normal);
|
||||
}
|
||||
if (vec3_dot(brush_inst->faces[f0].plane_normal, brush_inst->faces[f2].plane_normal) > threshold)
|
||||
{
|
||||
normal = vec3_add(normal, brush_inst->faces[f2].plane_normal);
|
||||
}
|
||||
normal = vec3_normalize(normal);
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = vec3_normalize(
|
||||
vec3_add(
|
||||
brush_inst->faces[f0].plane_normal,
|
||||
vec3_add(
|
||||
brush_inst->faces[f1].plane_normal,
|
||||
brush_inst->faces[f2].plane_normal)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = face_inst->plane_normal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
texture_data *texture = map_data_get_texture(face_inst->texture_idx);
|
||||
|
||||
@@ -242,6 +279,7 @@ void generate_brush_vertices(int entity_idx, int brush_idx)
|
||||
tangent = get_standard_tangent(face_inst);
|
||||
}
|
||||
|
||||
|
||||
bool unique_vertex = true;
|
||||
int duplicate_index = -1;
|
||||
|
||||
@@ -262,10 +300,10 @@ void generate_brush_vertices(int entity_idx, int brush_idx)
|
||||
face_geo_inst->vertices = realloc(face_geo_inst->vertices, face_geo_inst->vertex_count * sizeof(face_vertex));
|
||||
face_geo_inst->vertices[face_geo_inst->vertex_count - 1] = (face_vertex){vertex, normal, uv, tangent};
|
||||
}
|
||||
//else if(phong)
|
||||
//{
|
||||
// face_geo_inst->vertices[duplicate_index].normal = vec3_add(face_geo_inst->vertices[duplicate_index].normal, normal);
|
||||
//}
|
||||
else if(phong)
|
||||
{
|
||||
face_geo_inst->vertices[duplicate_index].normal = vec3_add(face_geo_inst->vertices[duplicate_index].normal, normal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Nuake {
|
||||
|
||||
Window::Window()
|
||||
{
|
||||
m_Title = DEFAULT_TITLE;
|
||||
|
||||
Init();
|
||||
Renderer::Init();
|
||||
}
|
||||
@@ -75,6 +77,17 @@ namespace Nuake {
|
||||
return m_Scene;
|
||||
}
|
||||
|
||||
void Window::SetTitle(const std::string& title)
|
||||
{
|
||||
m_Title = title;
|
||||
glfwSetWindowTitle(m_Window, m_Title.c_str());
|
||||
}
|
||||
|
||||
std::string Window::GetTitle()
|
||||
{
|
||||
return m_Title;
|
||||
}
|
||||
|
||||
Ref<FrameBuffer> Window::GetFrameBuffer() const
|
||||
{
|
||||
return m_Framebuffer;
|
||||
@@ -96,7 +109,7 @@ namespace Nuake {
|
||||
}
|
||||
|
||||
{ // Create window
|
||||
m_Window = glfwCreateWindow(m_Width, m_Height, "Nuake - Dev build", NULL, NULL);
|
||||
m_Window = glfwCreateWindow(m_Width, m_Height, m_Title.c_str(), NULL, NULL);
|
||||
if (!m_Window)
|
||||
{
|
||||
Logger::Log("Window creation failed.", CRITICAL);
|
||||
@@ -123,13 +136,11 @@ namespace Nuake {
|
||||
// TODO: have clear color in environnement.
|
||||
glClearColor(0.f, 0.f, 0.f, 1.0f);
|
||||
|
||||
glfwSwapInterval(1);
|
||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
@@ -137,9 +148,7 @@ namespace Nuake {
|
||||
m_Framebuffer = CreateRef<FrameBuffer>(true, glm::vec2(1920, 1080));
|
||||
m_Framebuffer->SetTexture(CreateRef<Texture>(glm::vec2(1920, 1080), GL_RGB));
|
||||
|
||||
|
||||
|
||||
|
||||
// ImGui init
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
@@ -222,7 +231,6 @@ namespace Nuake {
|
||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
|
||||
|
||||
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(m_Window, true);
|
||||
ImGui_ImplOpenGL3_Init("#version 330");
|
||||
}
|
||||
@@ -230,7 +238,6 @@ namespace Nuake {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Window::Update(Timestep ts)
|
||||
{
|
||||
// TODO: have event here?
|
||||
@@ -242,8 +249,6 @@ namespace Nuake {
|
||||
m_Scene->FixedUpdate(ts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Window::Draw()
|
||||
{
|
||||
// Dont render if no scene is loaded.
|
||||
@@ -268,120 +273,6 @@ namespace Nuake {
|
||||
m_Scene->Draw(*m_Framebuffer.get(), m_Scene->m_EditorCamera->GetPerspective(), m_Scene->m_EditorCamera->GetTransform());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//m_GBuffer->Bind();
|
||||
//m_GBuffer->Clear();
|
||||
//{
|
||||
// if (Engine::IsPlayMode)
|
||||
// m_Scene->DrawDeferred();
|
||||
// else
|
||||
// m_Scene->EditorDrawDeferred();
|
||||
//}
|
||||
//
|
||||
//m_GBuffer->Unbind();
|
||||
//
|
||||
//m_DeferredBuffer->Bind();
|
||||
//m_DeferredBuffer->Clear();
|
||||
//{
|
||||
// glDisable(GL_CULL_FACE);
|
||||
//
|
||||
// if (Engine::IsPlayMode)
|
||||
// m_Scene->DrawDeferredShading();
|
||||
// else
|
||||
// m_Scene->EditorDrawDeferredShading();
|
||||
//
|
||||
// m_GBuffer->GetTexture(GL_DEPTH_ATTACHMENT)->Bind(5);
|
||||
// m_GBuffer->GetTexture(GL_COLOR_ATTACHMENT0)->Bind(6);
|
||||
// m_GBuffer->GetTexture(GL_COLOR_ATTACHMENT1)->Bind(7);
|
||||
// m_GBuffer->GetTexture(GL_COLOR_ATTACHMENT2)->Bind(8);
|
||||
//
|
||||
// glDisable(GL_CULL_FACE);
|
||||
//
|
||||
// Shader* deferredShader = ShaderManager::GetShader("resources/Shaders/deferred.shader");
|
||||
// deferredShader->Bind();
|
||||
// deferredShader->SetUniform1i("m_Depth", 5);
|
||||
// deferredShader->SetUniform1i("m_Albedo", 6);
|
||||
// deferredShader->SetUniform1i("m_Normal", 7);
|
||||
// deferredShader->SetUniform1i("m_Material", 8);
|
||||
//
|
||||
// Renderer::DrawQuad(Matrix4());
|
||||
//
|
||||
// auto interfaceView = m_Scene->m_Registry.view<InterfaceComponent>();
|
||||
// for (auto i : interfaceView)
|
||||
// {
|
||||
// InterfaceComponent& uInterface = interfaceView.get<InterfaceComponent>(i);
|
||||
// if (uInterface.Interface)
|
||||
// uInterface.Interface->Draw(m_DeferredBuffer->GetSize());
|
||||
// }
|
||||
//}
|
||||
//m_DeferredBuffer->Unbind();
|
||||
//
|
||||
//bloom.Threshold = GetScene()->GetEnvironment()->BloomThreshold;
|
||||
//bloom.BlurAmount = GetScene()->GetEnvironment()->BloomBlurAmount;
|
||||
//
|
||||
//bloom.Draw();
|
||||
|
||||
|
||||
|
||||
// m_BloomFrameBuffer->Bind();
|
||||
// m_BloomFrameBuffer->Clear();
|
||||
// m_BloomFrameBuffer->SetTexture(m_BloomTextures[0]);
|
||||
// {
|
||||
//
|
||||
// Ref<Shader> bloomShader = ShaderManager::GetShader("resources/Shaders/bloom.shader");
|
||||
// bloomShader->Bind();
|
||||
//
|
||||
// // Threshold
|
||||
// bloomShader->SetUniform1i("u_Stage", 0);
|
||||
// bloomShader->SetUniform1f("u_Threshold", 0.5);
|
||||
// m_DeferredBuffer->GetTexture()->Bind(1);
|
||||
// bloomShader->SetUniform1i("u_LightingBuffer", 1);
|
||||
//
|
||||
// Renderer::DrawQuad(Matrix4());
|
||||
|
||||
// Downsample
|
||||
|
||||
//m_BloomTextures.clear();
|
||||
//const int DownsampleAmount = 4;
|
||||
//m_BloomTextures.reserve(4);
|
||||
//m_BloomTextures.push_back(m_BloomFrameBuffer->GetTexture());
|
||||
//
|
||||
//Vector2 originalSize = m_BloomFrameBuffer->GetSize();
|
||||
//Vector2 currentSize = originalSize;
|
||||
//for (unsigned int i = 1; i < DownsampleAmount; i++) // # of iterations for down sample
|
||||
//{
|
||||
// m_BloomFrameBuffer->Clear();
|
||||
// currentSize /= 2;
|
||||
// m_BloomTextures.push_back(m_BloomFrameBuffer->GetTexture());
|
||||
//
|
||||
// m_BloomFrameBuffer->SetSize(currentSize);
|
||||
// m_BloomFrameBuffer->SetTexture(CreateRef<Texture>(currentSize, GL_RGB));
|
||||
//
|
||||
// m_BloomFrameBuffer->Clear();
|
||||
// bloomShader->SetUniform1i("u_Stage", 1);
|
||||
// bloomShader->SetUniform1i("u_DownsamplingSource", m_BloomTextures[i - 1]->GetID());
|
||||
// Renderer::DrawQuad(Matrix4());
|
||||
//
|
||||
// if (ImGui::Begin(("Downsample " + std::to_string(i)).c_str()))
|
||||
// {
|
||||
// ImGui::Image((void*)m_BloomTextures[i]->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
|
||||
// }
|
||||
// ImGui::End();
|
||||
//}
|
||||
|
||||
// Upsample
|
||||
|
||||
|
||||
//}
|
||||
//m_BloomFrameBuffer->Unbind();
|
||||
|
||||
//if (ImGui::Begin("Bloom"))
|
||||
//{
|
||||
// ImGui::Image((void*)bloom.GetThreshold()->GetID(), ImGui::GetContentRegionAvail(), ImVec2(0, 1), ImVec2(1, 0));
|
||||
//}
|
||||
//ImGui::End();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
Renderer::EndDraw();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,11 @@ namespace Nuake
|
||||
class Window
|
||||
{
|
||||
private:
|
||||
const std::string DEFAULT_TITLE = "Untitled Window";
|
||||
|
||||
static Ref<Window> s_Instance;
|
||||
|
||||
std::string m_Title;
|
||||
int m_Width = 1280;
|
||||
int m_Height = 720;
|
||||
|
||||
@@ -42,6 +45,9 @@ namespace Nuake
|
||||
Vector2 GetSize();
|
||||
Ref<Scene> GetScene();
|
||||
bool SetScene(Ref<Scene> scene);
|
||||
|
||||
void SetTitle(const std::string& title);
|
||||
std::string GetTitle();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user