Transform system overhaul
Fixed child rotations Added editor overhauls
This commit is contained in:
@@ -93,28 +93,28 @@ int main()
|
||||
for (auto e : camView) {
|
||||
auto [transformComponent, cam] = camView.get<Nuake::TransformComponent, Nuake::CameraComponent>(e);
|
||||
|
||||
GuizmoShader->SetUniformMat4f("model", transformComponent.GetTransform());
|
||||
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.GetTransform());
|
||||
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.GetTransform());
|
||||
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.GetTransform());
|
||||
Nuake::Renderer::DrawQuad(transformComponent.GetGlobalTransform());
|
||||
}
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -130,7 +130,7 @@ int main()
|
||||
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>().GetTransform());
|
||||
Nuake::Renderer::SubmitMesh(m, editor.m_SelectedEntity.GetComponent<Nuake::TransformComponent>().GetGlobalTransform());
|
||||
|
||||
Nuake::Renderer::Flush(ditherShader, true);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ uniform sampler2D m_Material;
|
||||
uniform sampler2D m_Normal;
|
||||
|
||||
// Lights
|
||||
const int MaxLight = 20;
|
||||
const int MaxLight = 29;
|
||||
uniform int LightCount = 0;
|
||||
|
||||
struct Light {
|
||||
@@ -55,20 +55,15 @@ struct Light {
|
||||
vec3 Color;
|
||||
float Strength;
|
||||
vec3 Position;
|
||||
float ConstantAttenuation;
|
||||
float LinearAttenuation;
|
||||
float QuadraticAttenuation;
|
||||
mat4 LightTransform;
|
||||
sampler2D ShadowMaps[4];
|
||||
int ShadowMapsIDs[4];
|
||||
float CascadeDepth[4];
|
||||
mat4 LightTransforms[4];
|
||||
sampler2D ShadowMap;
|
||||
sampler2D RSMFlux;
|
||||
sampler2D RSMNormal;
|
||||
sampler2D RSMPos;
|
||||
int Volumetric;
|
||||
};
|
||||
|
||||
uniform sampler2D ShadowMaps[4];
|
||||
|
||||
uniform Light Lights[MaxLight];
|
||||
|
||||
// Converts depth to World space coords.
|
||||
@@ -166,7 +161,7 @@ float ShadowCalculation(Light light, vec3 FragPos, vec3 normal)
|
||||
|
||||
float shadow = 0.0;
|
||||
|
||||
float pcfDepth = texture(light.ShadowMaps[0], projCoords.xy).r;
|
||||
float pcfDepth = texture(ShadowMaps[0], projCoords.xy).r;
|
||||
return currentDepth - bias > pcfDepth ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
@@ -206,9 +201,9 @@ vec3 ComputeVolumetric(vec3 FragPos, Light light)
|
||||
float currentDepth = projCoords.z;
|
||||
|
||||
// get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
|
||||
vec2 texelSize = 1.0 / textureSize(light.ShadowMaps[0], 0);
|
||||
vec2 texelSize = 1.0 / textureSize(ShadowMaps[0], 0);
|
||||
|
||||
float closestDepth = texture(light.ShadowMaps[0], projCoords.xy).r;
|
||||
float closestDepth = texture(ShadowMaps[0], projCoords.xy).r;
|
||||
|
||||
if (closestDepth > currentDepth)
|
||||
accumFog += (ComputeScattering(dot(rayDirection, light.Direction)).xxx * light.Color);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Nuake {
|
||||
void EditorInterface::Init()
|
||||
{
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_AutoHideTabBar;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->GetWorkPos());
|
||||
ImGui::SetNextWindowSize(viewport->GetWorkSize());
|
||||
@@ -49,7 +49,6 @@ namespace Nuake {
|
||||
|
||||
ImGuiID dockspace_id = ImGui::GetID("MyDockSpace");
|
||||
ImGui::DockSpaceOverViewport(viewport, dockspace_flags);
|
||||
|
||||
//this->filesystem = FileSystemUI();
|
||||
}
|
||||
|
||||
@@ -93,37 +92,52 @@ namespace Nuake {
|
||||
{
|
||||
TransformComponent& tc = m_SelectedEntity.GetComponent<TransformComponent>();
|
||||
ParentComponent& parent = m_SelectedEntity.GetComponent<ParentComponent>();
|
||||
Matrix4 oldTransform = tc.GetTransform();
|
||||
Matrix4 oldTransform = tc.GetGlobalTransform();
|
||||
Vector3 oldRotation = tc.Rotation;
|
||||
ImGuizmo::Manipulate(
|
||||
glm::value_ptr(Engine::GetCurrentScene()->GetCurrentCamera()->GetTransform()),
|
||||
glm::value_ptr(Engine::GetCurrentScene()->GetCurrentCamera()->GetPerspective()),
|
||||
CurrentOperation, CurrentMode, glm::value_ptr(oldTransform), 0, 0
|
||||
);
|
||||
|
||||
if (ImGuizmo::IsUsing())
|
||||
{
|
||||
Vector3 globalPos = Vector3();
|
||||
Entity currentParent = m_SelectedEntity;
|
||||
if (parent.HasParent)
|
||||
{
|
||||
Matrix4 inverseParent = glm::inverse(parent.Parent.GetComponent<TransformComponent>().GlobalTransform);
|
||||
oldTransform *= inverseParent;
|
||||
}
|
||||
|
||||
Vector3 scale;
|
||||
glm::quat rotation;
|
||||
Vector3 translation;
|
||||
Vector3 skew;
|
||||
Vector4 perspective;
|
||||
glm::decompose(oldTransform, scale, rotation, translation, skew, perspective);
|
||||
//rotation = glm::conjugate(rotation);
|
||||
if (scale.x < 0 && scale.y < 0 && scale.z < 0)
|
||||
scale = glm::vec3(0, 0, 0);
|
||||
|
||||
rotation = glm::conjugate(rotation);
|
||||
Vector3 euler = glm::eulerAngles(rotation);
|
||||
|
||||
Vector3 globalPos = Vector3();
|
||||
Entity currentParent = m_SelectedEntity;
|
||||
if (parent.HasParent)
|
||||
if(CurrentOperation == ImGuizmo::TRANSLATE)
|
||||
tc.Translation = translation;
|
||||
if (CurrentOperation == ImGuizmo::ROTATE)
|
||||
{
|
||||
globalPos -= parent.Parent.GetComponent<TransformComponent>().GlobalTranslation;
|
||||
translation -= globalPos;
|
||||
}
|
||||
float signX = 1.0f;
|
||||
if (oldRotation.x < 0.0f) signX = -1.0f;
|
||||
float signY = 1.0f;
|
||||
if (oldRotation.y < 0.0f) signY = -1.0f;
|
||||
float signZ = 1.0f;
|
||||
if (oldRotation.z < 0.0f) signZ = -1.0f;
|
||||
|
||||
tc.Translation = translation;
|
||||
tc.Rotation = glm::vec3(glm::degrees(euler.x), glm::degrees(euler.y), glm::degrees(euler.z));
|
||||
tc.Scale = scale;
|
||||
tc.Rotation = glm::vec3(glm::degrees(euler.x),
|
||||
glm::degrees(euler.y),
|
||||
glm::degrees(euler.z));
|
||||
}
|
||||
|
||||
if (CurrentOperation == ImGuizmo::SCALE)
|
||||
tc.Scale = scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -534,12 +548,53 @@ namespace Nuake {
|
||||
component.LoadModel();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Reimport"))
|
||||
{
|
||||
component.LoadModel();
|
||||
}
|
||||
|
||||
ImGui::Indent(16.0f);
|
||||
if (ImGui::CollapsingHeader("Meshes"))
|
||||
{
|
||||
ImGui::Indent(16.0f);
|
||||
uint16_t index = 0;
|
||||
for (auto& m : component.meshes)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(std::to_string(index).c_str()))
|
||||
{
|
||||
std::string materialName = "No material";
|
||||
if (m->m_Material)
|
||||
materialName = m->m_Material->GetName();
|
||||
|
||||
ImGui::Indent(16.0f);
|
||||
if (ImGui::CollapsingHeader(materialName.c_str()))
|
||||
{
|
||||
//if (ImGui::BeginChild("Material child", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
//{
|
||||
ImGui::Indent(16.0f);
|
||||
DrawMaterialEditor(m->m_Material);
|
||||
//}
|
||||
//ImGui::EndChild();
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Material"))
|
||||
{
|
||||
char* file = (char*)payload->Data;
|
||||
std::string fullPath = std::string(file, 256);
|
||||
path = FileSystem::AbsoluteToRelative(fullPath);
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
@@ -701,6 +756,8 @@ namespace Nuake {
|
||||
|
||||
component.Path = path;
|
||||
|
||||
ImGui::InputFloat("Scale factor", &component.ScaleFactor, 0.01f, 0.1f);
|
||||
|
||||
ImGui::Checkbox("Build collisions", &component.HasCollisions);
|
||||
if (ImGui::Button("Build Geometry"))
|
||||
{
|
||||
@@ -984,6 +1041,101 @@ namespace Nuake {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void EditorInterface::DrawMaterialEditor(Ref<Material> material)
|
||||
{
|
||||
|
||||
ImGui::Text("Flags");
|
||||
bool unlit = material->data.u_Unlit == 1;
|
||||
ImGui::Checkbox("Unlit", &unlit);
|
||||
material->data.u_Unlit = (int)unlit;
|
||||
if (ImGui::CollapsingHeader("Albedo", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasAlbedo())
|
||||
textureID = material->m_Albedo->GetID();
|
||||
|
||||
|
||||
ImGui::ColorEdit3("Color", &material->data.m_AlbedoColor.r);
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image1"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(0, 0, 0, 0), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
if (texture != "" && texture != material->m_Albedo->GetPath())
|
||||
material->m_Albedo = TextureManager::Get()->GetTexture(texture);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
bool isAlbedo = material->data.u_HasAlbedo == 1;
|
||||
ImGui::Checkbox("Use##1", &isAlbedo);
|
||||
material->data.u_HasAlbedo = (int)isAlbedo;
|
||||
|
||||
}
|
||||
if (ImGui::CollapsingHeader("AO", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasAO())
|
||||
textureID = material->m_AO->GetID();
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image2"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("Image files (*.png) | *.png | Image files (*.jpg) | *.jpg");
|
||||
if (texture != "")
|
||||
{
|
||||
m_SelectedMaterial->SetAO(TextureManager::Get()->GetTexture(texture));
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
bool hasAO = material->data.u_HasAO == 1;
|
||||
ImGui::Checkbox("Use##1", &hasAO);
|
||||
material->data.u_HasAO = (int)hasAO;
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::DragFloat("Value##2", &material->data.u_AOValue, 0.01f, 0.0f, 1.0f);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Normal", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasNormal())
|
||||
textureID = material->m_Normal->GetID();
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image3"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png");
|
||||
if (texture != "")
|
||||
{
|
||||
material->SetNormal(TextureManager::Get()->GetTexture(texture));
|
||||
}
|
||||
}
|
||||
//ImGui::SameLine();
|
||||
//ImGui::Checkbox("Use##3", &m_SelectedMaterial->data.u_HasNormal);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Metalness", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasMetalness())
|
||||
textureID = material->m_Metalness->GetID();
|
||||
if (ImGui::ImageButtonEx(ImGui::GetCurrentWindow()->GetID("#image4"), (void*)textureID, ImVec2(80, 80), ImVec2(0, 1), ImVec2(1, 0), ImVec2(2, 2), ImVec4(0, 0, 0, 1), ImVec4(1, 1, 1, 1)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
//ImGui::Checkbox("Use##4", &m_SelectedMaterial->data.u_HasMetalness);
|
||||
ImGui::SameLine();
|
||||
ImGui::DragFloat("Value##4", &material->data.u_MetalnessValue, 0.01f, 0.0f, 1.0f);
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Roughness", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
unsigned int textureID = 0;
|
||||
if (material->HasRougness())
|
||||
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)))
|
||||
{
|
||||
std::string texture = FileDialog::OpenFile("*.png | *.jpg");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
//ImGui::Checkbox("Use##5", &m_SelectedMaterial->data.u_HasRoughness);
|
||||
ImGui::SameLine();
|
||||
ImGui::DragFloat("Value##5", &material->data.u_RoughnessValue, 0.01f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EditorInterface::DrawRessourceWindow()
|
||||
{
|
||||
@@ -1388,6 +1540,15 @@ namespace Nuake {
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_EXPAND_ALT)) CurrentOperation = ImGuizmo::OPERATION::SCALE;
|
||||
ImGui::SameLine();
|
||||
|
||||
float availWidth = ImGui::GetContentRegionAvailWidth();
|
||||
float windowWidth = ImGui::GetWindowWidth();
|
||||
|
||||
float used = windowWidth - availWidth;
|
||||
float half = windowWidth / 2.0;
|
||||
float needed = half - used;
|
||||
ImGui::Dummy(ImVec2(needed, 10));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_PLAY)) Engine::EnterPlayMode();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button(ICON_FA_STOP)) Engine::ExitPlayMode();
|
||||
|
||||
@@ -48,5 +48,6 @@ namespace Nuake {
|
||||
void DrawInit();
|
||||
void EditorInterfaceDrawFiletree(Ref<Directory> dir);
|
||||
void Overlay();
|
||||
void DrawMaterialEditor(Ref<Material> material);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Nuake
|
||||
int idx = m_Lights.size();
|
||||
|
||||
Vector3 direction = light.GetDirection();
|
||||
Vector3 pos = transform.GetTransform()[3];
|
||||
Vector3 pos = transform.GetGlobalTransform()[3];
|
||||
Matrix4 lightView = glm::lookAt(pos, pos - direction, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
//light.m_Framebuffer->GetTexture(GL_DEPTH_ATTACHMENT)->Bind(17);
|
||||
@@ -180,7 +180,8 @@ namespace Nuake
|
||||
for (unsigned int i = 0; i < CSM_AMOUNT; i++)
|
||||
{
|
||||
light.m_Framebuffers[i]->GetTexture(GL_DEPTH_ATTACHMENT)->Bind(17 + i);
|
||||
deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].ShadowMaps[" + std::to_string(i) + "]", 17 + i);
|
||||
deferredShader->SetUniform1i("ShadowMaps[" + std::to_string(i) + "]", 17 + i);
|
||||
deferredShader->SetUniform1i("Lights[" + std::to_string(idx - 1) + "].ShadowMapsIDs[" + std::to_string(i) + "]", i);
|
||||
deferredShader->SetUniform1f("Lights[" + std::to_string(idx - 1) + "].CascadeDepth[" + std::to_string(i) + "]", light.mCascadeSplitDepth[i]);
|
||||
deferredShader->SetUniformMat4f("Lights[" + std::to_string(idx - 1) + "].LightTransforms[" + std::to_string(i) + "]", light.mViewProjections[i]);
|
||||
}
|
||||
@@ -205,7 +206,7 @@ namespace Nuake
|
||||
void Renderer::DrawCube(TransformComponent transform, glm::vec4 color)
|
||||
{
|
||||
//glDisable(GL_DEPTH_TEST);
|
||||
m_DebugShader->SetUniformMat4f("u_Model", transform.GetTransform());
|
||||
m_DebugShader->SetUniformMat4f("u_Model", transform.GetGlobalTransform());
|
||||
m_DebugShader->SetUniform4f("u_Color", color.r, color.g, color.b, color.a);
|
||||
|
||||
CubeVertexArray->Bind();
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Nuake {
|
||||
public:
|
||||
std::vector<Ref<Mesh>> m_Meshes;
|
||||
std::string Path;
|
||||
float ScaleFactor = 1.0f;
|
||||
bool HasCollisions = false;
|
||||
void Load(std::string path, bool collisions);
|
||||
|
||||
|
||||
@@ -11,14 +11,13 @@ namespace Nuake
|
||||
Scale = Vector3(1, 1, 1);
|
||||
}
|
||||
|
||||
glm::mat4 TransformComponent::GetTransform()
|
||||
Matrix4 TransformComponent::GetGlobalTransform() const
|
||||
{
|
||||
//Matrix4 transform = Matrix4(1.0f);
|
||||
//transform = glm::translate(transform, GlobalTranslation);
|
||||
//transform = glm::rotate(transform, glm::radians(Rotation.x), Vector3(1, 0, 0));
|
||||
//transform = glm::rotate(transform, glm::radians(Rotation.y), Vector3(0, 1, 0));
|
||||
//transform = glm::rotate(transform, glm::radians(Rotation.z), Vector3(0, 0, 1));
|
||||
//transform = glm::scale(transform, Scale);
|
||||
return Transform;
|
||||
return GlobalTransform;
|
||||
}
|
||||
|
||||
Matrix4 TransformComponent::GetLocalTransform() const
|
||||
{
|
||||
return LocalTransform;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,21 @@ namespace Nuake
|
||||
{
|
||||
class TransformComponent {
|
||||
public:
|
||||
Vector3 GlobalTranslation;
|
||||
Vector3 Translation;
|
||||
Matrix4 Transform;
|
||||
|
||||
Vector3 GlobalRotation;
|
||||
Vector3 Rotation; // TODO: Should use quaternions.
|
||||
|
||||
Vector3 GlobalScale;
|
||||
Vector3 Scale;
|
||||
|
||||
Vector3 GlobalTranslation;
|
||||
Vector3 GlobalRotation;
|
||||
Vector3 GlobalScale;
|
||||
|
||||
Matrix4 LocalTransform;
|
||||
Matrix4 GlobalTransform;
|
||||
|
||||
TransformComponent();
|
||||
|
||||
Matrix4 GetTransform();
|
||||
Matrix4 GetGlobalTransform() const;
|
||||
Matrix4 GetLocalTransform() const;
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
|
||||
@@ -199,7 +199,7 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, mesh] = meshView.get<TransformComponent, MeshComponent>(e);
|
||||
for(auto& m : mesh.meshes)
|
||||
Renderer::SubmitMesh(m, transform.GetTransform());
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
|
||||
auto quakeView = m_Registry.view<TransformComponent, BSPBrushComponent>();
|
||||
@@ -213,11 +213,11 @@ namespace Nuake {
|
||||
for (Ref<Mesh>& m : model.Meshes)
|
||||
{
|
||||
AABB modelAABB = m->GetAABB();
|
||||
modelAABB.Transform(transform.GetTransform());
|
||||
modelAABB.Transform(transform.GetGlobalTransform());
|
||||
|
||||
bool isInFrustum = lightFrustum.IsBoxVisible(modelAABB.Min, modelAABB.Max);
|
||||
if (isInFrustum)
|
||||
Renderer::SubmitMesh(m, transform.GetTransform());
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, model, parent] = view.get<TransformComponent, MeshComponent, ParentComponent>(e);
|
||||
for (auto& m : model.meshes)
|
||||
Renderer::SubmitMesh(m, transform.GetTransform());
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
@@ -305,7 +305,7 @@ namespace Nuake {
|
||||
|
||||
for (auto& b : model.Meshes)
|
||||
{
|
||||
Renderer::SubmitMesh(b, transform.GetTransform());
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,6 +315,101 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::DrawDeferred()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
Ref<Camera> cam = nullptr;
|
||||
{
|
||||
auto view = m_Registry.view<TransformComponent, CameraComponent, ParentComponent>();
|
||||
for (auto e : view) {
|
||||
auto [transform, camera, parent] = view.get<TransformComponent, CameraComponent, ParentComponent>(e);
|
||||
cam = camera.CameraInstance;
|
||||
cam->Translation = transform.GlobalTranslation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cam)
|
||||
return;
|
||||
|
||||
Ref<Shader> gBufferShader = ShaderManager::GetShader("resources/Shaders/gbuffer.shader");
|
||||
gBufferShader->Bind();
|
||||
gBufferShader->SetUniformMat4f("u_Projection", cam->GetPerspective());
|
||||
gBufferShader->SetUniformMat4f("u_View", cam->GetTransform());
|
||||
|
||||
auto view = m_Registry.view<TransformComponent, MeshComponent, ParentComponent>();
|
||||
for (auto e : view)
|
||||
{
|
||||
auto [transform, mesh, parent] = view.get<TransformComponent, MeshComponent, ParentComponent>(e);
|
||||
for (auto& m : mesh.meshes)
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
|
||||
auto quakeView = m_Registry.view<TransformComponent, BSPBrushComponent, ParentComponent>();
|
||||
for (auto e : quakeView)
|
||||
{
|
||||
auto [transform, model, parent] = quakeView.get<TransformComponent, BSPBrushComponent, ParentComponent>(e);
|
||||
|
||||
if (model.IsTransparent)
|
||||
continue;
|
||||
|
||||
for (auto& b : model.Meshes)
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform());
|
||||
}
|
||||
glCullFace(GL_FRONT);
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
}
|
||||
|
||||
void Scene::DrawDeferredShading()
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
Ref<Camera> cam = nullptr;
|
||||
{
|
||||
auto view = m_Registry.view<TransformComponent, CameraComponent, ParentComponent>();
|
||||
for (auto e : view) {
|
||||
auto [transform, camera, parent] = view.get<TransformComponent, CameraComponent, ParentComponent>(e);
|
||||
cam = camera.CameraInstance;
|
||||
cam->Translation = transform.GlobalTranslation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cam)
|
||||
return;
|
||||
|
||||
if (GetEnvironment()->ProceduralSkybox)
|
||||
GetEnvironment()->ProceduralSkybox->Draw(cam);
|
||||
|
||||
Ref<Shader> deferredShader = ShaderManager::GetShader("resources/Shaders/deferred.shader");
|
||||
deferredShader->Bind();
|
||||
deferredShader->SetUniformMat4f("u_Projection", cam->GetPerspective());
|
||||
deferredShader->SetUniformMat4f("u_View", cam->GetTransform());
|
||||
deferredShader->SetUniform1f("u_Exposure", 1.0);
|
||||
|
||||
Vector3 camPosition = cam->GetTranslation();
|
||||
deferredShader->SetUniform3f("u_EyePosition", camPosition.x, camPosition.y, camPosition.z);
|
||||
|
||||
Ref<Environment> env = GetEnvironment();
|
||||
deferredShader->SetUniform1f("u_FogAmount", env->VolumetricFog);
|
||||
deferredShader->SetUniform1f("u_FogStepCount", env->VolumetricStepCount);
|
||||
|
||||
auto view = m_Registry.view<TransformComponent, LightComponent, ParentComponent>();
|
||||
for (auto l : view)
|
||||
{
|
||||
auto [transform, light, parent] = view.get<TransformComponent, LightComponent, ParentComponent>(l);
|
||||
|
||||
if (light.SyncDirectionWithSky)
|
||||
light.Direction = GetEnvironment()->ProceduralSkybox->GetSunDirection();
|
||||
|
||||
Renderer::RegisterDeferredLight(transform, light);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::EditorDraw()
|
||||
{
|
||||
Ref<Environment> env = GetEnvironment();
|
||||
@@ -359,7 +454,7 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, mesh, parent] = view.get<TransformComponent, MeshComponent, ParentComponent>(e);
|
||||
for(auto& m : mesh.meshes)
|
||||
Renderer::SubmitMesh(m, transform.GetTransform());
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
glCullFace(GL_BACK);
|
||||
Renderer::Flush(pbrShader);
|
||||
@@ -373,7 +468,7 @@ namespace Nuake {
|
||||
continue;
|
||||
|
||||
for (auto& b : model.Meshes)
|
||||
Renderer::SubmitMesh(b, transform.GetTransform());
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform());
|
||||
}
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
@@ -398,7 +493,7 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, box, parent] = sphereCollider.get<TransformComponent, SphereColliderComponent, ParentComponent>(e);
|
||||
|
||||
flatShader->SetUniformMat4f("u_Model", transform.GetTransform());
|
||||
flatShader->SetUniformMat4f("u_Model", transform.GetGlobalTransform());
|
||||
|
||||
TransformComponent t = transform;
|
||||
t.Scale = (box.Radius * 2.f) * transform.Scale;
|
||||
@@ -413,12 +508,12 @@ namespace Nuake {
|
||||
if (!model.IsTransparent)
|
||||
continue;
|
||||
|
||||
flatShader->SetUniformMat4f("u_Model", transform.GetTransform());
|
||||
flatShader->SetUniformMat4f("u_Model", transform.GetGlobalTransform());
|
||||
flatShader->SetUniform4f("u_Color", 1.f, 0.0f, 0.1f, 0.5f);
|
||||
|
||||
for (auto& b : model.Meshes)
|
||||
{
|
||||
Renderer::SubmitMesh(b, transform.GetTransform());
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,8 +535,10 @@ namespace Nuake {
|
||||
{
|
||||
auto [transform, mesh, parent] = view.get<TransformComponent, MeshComponent, ParentComponent>(e);
|
||||
for (auto& m : mesh.meshes)
|
||||
Renderer::SubmitMesh(m, transform.GetTransform());
|
||||
Renderer::SubmitMesh(m, transform.GetGlobalTransform());
|
||||
}
|
||||
glCullFace(GL_BACK);
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
|
||||
auto quakeView = m_Registry.view<TransformComponent, BSPBrushComponent, ParentComponent>();
|
||||
for (auto e : quakeView)
|
||||
@@ -452,7 +549,7 @@ namespace Nuake {
|
||||
continue;
|
||||
|
||||
for (auto& b : model.Meshes)
|
||||
Renderer::SubmitMesh(b, transform.GetTransform());
|
||||
Renderer::SubmitMesh(b, transform.GetGlobalTransform());
|
||||
}
|
||||
glCullFace(GL_FRONT);
|
||||
Renderer::Flush(gBufferShader, false);
|
||||
@@ -461,12 +558,13 @@ namespace Nuake {
|
||||
void Scene::EditorDrawDeferredShading()
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
if (GetEnvironment()->ProceduralSkybox)
|
||||
GetEnvironment()->ProceduralSkybox->Draw(m_EditorCamera);
|
||||
|
||||
Ref<Shader> deferredShader = ShaderManager::GetShader("resources/Shaders/deferred.shader");
|
||||
deferredShader->Bind();
|
||||
deferredShader->SetUniformMat4f("u_Projection", m_EditorCamera->GetPerspective());
|
||||
deferredShader->SetUniformMat4f("u_View", m_EditorCamera->GetTransform());
|
||||
|
||||
deferredShader->SetUniform1f("u_Exposure", 1.0);
|
||||
|
||||
Vector3 camPosition = m_EditorCamera->GetTranslation();
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace Nuake {
|
||||
void DrawShadows();
|
||||
void DrawInterface(Vector2 screensize);
|
||||
void Draw();
|
||||
void DrawDeferred();
|
||||
void DrawDeferredShading();
|
||||
void EditorDrawDeferred();
|
||||
void EditorDrawDeferredShading();
|
||||
void EditorDraw();
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace Nuake {
|
||||
parent.AddChild(brushEntity);
|
||||
|
||||
transformComponent.Translation = Vector3(brush->center.y * (1.0f / 64),
|
||||
brush->center.z * (1.0f / 64),
|
||||
brush->center.x * (1.0f / 64));
|
||||
brush->center.z * ScaleFactor * (1.0f / 64),
|
||||
brush->center.x * ScaleFactor * (1.0f / 64));
|
||||
|
||||
BSPBrushComponent& bsp = brushEntity.AddComponent<BSPBrushComponent>();
|
||||
bsp.IsSolid = false;
|
||||
@@ -66,9 +66,9 @@ namespace Nuake {
|
||||
face_vertex vertex = face_geo_inst->vertices[i];
|
||||
|
||||
Vector3 vertexPos = Vector3(
|
||||
(vertex.vertex.y - brush->center.y) * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * (1.0f / 64)
|
||||
(vertex.vertex.y - brush->center.y) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * ScaleFactor * (1.0f / 64)
|
||||
);
|
||||
|
||||
Vector3 vertexNormal = Vector3(vertex.normal.y, vertex.normal.z, vertex.normal.x);
|
||||
@@ -107,9 +107,9 @@ namespace Nuake {
|
||||
parent.AddChild(brushEntity);
|
||||
|
||||
transformComponent.Translation = Vector3(
|
||||
brush->center.y * (1.0f / 64),
|
||||
brush->center.z * (1.0f / 64),
|
||||
brush->center.x * (1.0f / 64));
|
||||
brush->center.y * ScaleFactor * (1.0f / 64),
|
||||
brush->center.z * ScaleFactor * (1.0f / 64),
|
||||
brush->center.x * ScaleFactor * (1.0f / 64));
|
||||
|
||||
int index_offset = 0;
|
||||
int lastTextureID = -1;
|
||||
@@ -141,9 +141,9 @@ namespace Nuake {
|
||||
vertex_uv vertex_uv = get_valve_uv(vertex.vertex, face, texture->width, texture->height);
|
||||
|
||||
Vector3 vertexPos = Vector3(
|
||||
(vertex.vertex.y - brush->center.y) * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * (1.0f / 64)
|
||||
(vertex.vertex.y - brush->center.y) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * ScaleFactor * (1.0f / 64)
|
||||
);
|
||||
|
||||
Vector2 vertexUV = Vector2(vertex_uv.u, vertex_uv.v);
|
||||
@@ -227,9 +227,9 @@ namespace Nuake {
|
||||
parent.AddChild(brushEntity);
|
||||
|
||||
transformComponent.Translation = Vector3(
|
||||
brush->center.y * (1.0f / 64),
|
||||
brush->center.z * (1.0f / 64),
|
||||
brush->center.x * (1.0f / 64));
|
||||
brush->center.y * ScaleFactor * (1.0f / 64),
|
||||
brush->center.z * ScaleFactor * (1.0f / 64),
|
||||
brush->center.x * ScaleFactor * (1.0f / 64));
|
||||
|
||||
int index_offset = 0;
|
||||
int lastTextureID = -1;
|
||||
@@ -260,9 +260,9 @@ namespace Nuake {
|
||||
vertex_uv vertex_uv = get_valve_uv(vertex.vertex, face, texture->width, texture->height);
|
||||
|
||||
Vector3 vertexPos = Vector3(
|
||||
(vertex.vertex.y - brush->center.y) * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * (1.0f / 64)
|
||||
(vertex.vertex.y - brush->center.y) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.z - brush->center.z) * ScaleFactor * (1.0f / 64),
|
||||
(vertex.vertex.x - brush->center.x) * ScaleFactor * (1.0f / 64)
|
||||
);
|
||||
|
||||
Vector2 vertexUV = Vector2(vertex_uv.u, vertex_uv.v);
|
||||
@@ -378,7 +378,7 @@ namespace Nuake {
|
||||
float y = String::ToFloat(splits[2]);
|
||||
float z = String::ToFloat(splits[0]);
|
||||
|
||||
Vector3 position = Vector3(x, y, z) * SCALE_FACTOR;
|
||||
Vector3 position = Vector3(x, y, z) * (ScaleFactor * (1.0f / 64.0f));
|
||||
newEntity.GetComponent<TransformComponent>().Translation = position;
|
||||
}
|
||||
|
||||
@@ -476,9 +476,9 @@ namespace Nuake {
|
||||
vertex_uv vertex_uv = get_valve_uv(vertex.vertex, face, texture->width, texture->height);
|
||||
|
||||
Vector3 vertexPos = Vector3(
|
||||
vertex.vertex.y,
|
||||
vertex.vertex.z,
|
||||
vertex.vertex.x
|
||||
vertex.vertex.y * quakeMapC.ScaleFactor,
|
||||
vertex.vertex.z * quakeMapC.ScaleFactor,
|
||||
vertex.vertex.x * quakeMapC.ScaleFactor
|
||||
);
|
||||
|
||||
Vector2 vertexUV = Vector2(vertex_uv.u, 1.0 - vertex_uv.v);
|
||||
@@ -487,7 +487,7 @@ namespace Nuake {
|
||||
Vector3 vertexBitangent = glm::cross(vertexNormal, vertexTangent) * (float)vertex.tangent.w;
|
||||
|
||||
vertices.push_back(Vertex {
|
||||
vertexPos * SCALE_FACTOR,
|
||||
vertexPos * (1.0f/64.0f),
|
||||
vertexUV,
|
||||
vertexNormal,
|
||||
vertexTangent,
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Nuake {
|
||||
class QuakeMapBuilder
|
||||
{
|
||||
private:
|
||||
const float SCALE_FACTOR = 1.f / 64.f;
|
||||
float ScaleFactor = 1.f;
|
||||
void CreateTrigger(brush* brush, brush_geometry* brush_inst,
|
||||
Scene* scene, Entity& parent,
|
||||
const std::string& target, const std::string& targetname);
|
||||
|
||||
@@ -43,70 +43,61 @@ namespace Nuake {
|
||||
Matrix4 cameraTransform = camera.CameraInstance->GetTransformRotation();
|
||||
}
|
||||
|
||||
// Calculate all local transforms
|
||||
auto localTransformView = m_Scene->m_Registry.view<TransformComponent>();
|
||||
for (auto tv : localTransformView)
|
||||
{
|
||||
TransformComponent& transform = localTransformView.get<TransformComponent>(tv);
|
||||
|
||||
Matrix4 localTransform = Matrix4(1.0f);
|
||||
localTransform = glm::translate(localTransform, transform.Translation);
|
||||
localTransform = glm::rotate(localTransform, glm::radians(transform.Rotation.x), Vector3(1, 0, 0));
|
||||
localTransform = glm::rotate(localTransform, glm::radians(transform.Rotation.y), Vector3(0, 1, 0));
|
||||
localTransform = glm::rotate(localTransform, glm::radians(transform.Rotation.z), Vector3(0, 0, 1));
|
||||
localTransform = glm::scale(localTransform, transform.Scale);
|
||||
|
||||
transform.LocalTransform = localTransform;
|
||||
}
|
||||
|
||||
// Calculate all global transforms
|
||||
auto transformView = m_Scene->m_Registry.view<ParentComponent, TransformComponent>();
|
||||
for (auto e : transformView)
|
||||
{
|
||||
auto [parent, transform] = transformView.get<ParentComponent, TransformComponent>(e);
|
||||
|
||||
if (!parent.HasParent)
|
||||
{
|
||||
// If no parents, then globalTransform is local transform.
|
||||
transform.GlobalTransform = transform.LocalTransform;
|
||||
}
|
||||
|
||||
Entity currentParent = Entity((entt::entity)e, m_Scene);
|
||||
|
||||
Matrix4 globalTransform = Matrix4(1.0f);
|
||||
Vector3 globalPosition = Vector3();
|
||||
Vector3 globalRotation = Vector3();
|
||||
Vector3 globalScale = Vector3();
|
||||
if (parent.HasParent)
|
||||
Matrix4 globalTransform = transform.LocalTransform;
|
||||
Vector3 globalPosition = transform.Translation;
|
||||
Vector3 globalRotation = transform.Rotation;
|
||||
Vector3 globalScale = transform.Scale;
|
||||
|
||||
ParentComponent parentComponent = currentParent.GetComponent<ParentComponent>();
|
||||
while (parentComponent.HasParent)
|
||||
{
|
||||
globalTransform = glm::translate(globalTransform, transform.Translation);
|
||||
TransformComponent& transformComponent = parentComponent.Parent.GetComponent<TransformComponent>();
|
||||
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.x), Vector3(1, 0, 0));
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.y), Vector3(0, 1, 0));
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.z), Vector3(0, 0, 1));
|
||||
globalTransform = transformComponent.LocalTransform * globalTransform;
|
||||
|
||||
globalTransform = glm::scale(globalTransform, transform.Scale);
|
||||
|
||||
ParentComponent parentComponent = currentParent.GetComponent<ParentComponent>();
|
||||
while (parentComponent.HasParent)
|
||||
{
|
||||
TransformComponent& transformComponent = parentComponent.Parent.GetComponent<TransformComponent>();
|
||||
|
||||
Matrix4 currentParentMatrix = Matrix4(1.0f);
|
||||
|
||||
currentParentMatrix = glm::translate(currentParentMatrix, transformComponent.Translation);
|
||||
|
||||
currentParentMatrix = glm::rotate(currentParentMatrix, glm::radians(transformComponent.Rotation.x), Vector3(1, 0, 0));
|
||||
currentParentMatrix = glm::rotate(currentParentMatrix, glm::radians(transformComponent.Rotation.y), Vector3(0, 1, 0));
|
||||
currentParentMatrix = glm::rotate(currentParentMatrix, glm::radians(transformComponent.Rotation.z), Vector3(0, 0, 1));
|
||||
|
||||
currentParentMatrix = glm::scale(currentParentMatrix, transformComponent.Scale);
|
||||
|
||||
globalTransform = currentParentMatrix * globalTransform;
|
||||
|
||||
globalPosition += transformComponent.Translation;
|
||||
globalRotation += transformComponent.Rotation;
|
||||
globalScale *= transformComponent.Scale;
|
||||
globalPosition += transformComponent.Translation;
|
||||
globalRotation += transformComponent.Rotation;
|
||||
globalScale *= transformComponent.Scale;
|
||||
|
||||
parentComponent = parentComponent.Parent.GetComponent<ParentComponent>();
|
||||
}
|
||||
parentComponent = parentComponent.Parent.GetComponent<ParentComponent>();
|
||||
}
|
||||
|
||||
|
||||
transform.GlobalTranslation = globalPosition + transform.Translation;
|
||||
transform.GlobalRotation = globalRotation + transform.Rotation;
|
||||
transform.GlobalScale = globalScale * transform.Scale;
|
||||
transform.GlobalTranslation = globalPosition;
|
||||
transform.GlobalRotation = globalRotation;
|
||||
transform.GlobalScale = globalScale;
|
||||
|
||||
transform.Transform = globalTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.GlobalTranslation = transform.Translation;
|
||||
transform.GlobalRotation = transform.Rotation;
|
||||
transform.Scale = transform.Scale;
|
||||
|
||||
globalTransform = glm::translate(globalTransform, transform.Translation);
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.x), Vector3(1, 0, 0));
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.y), Vector3(0, 1, 0));
|
||||
globalTransform = glm::rotate(globalTransform, glm::radians(transform.Rotation.z), Vector3(0, 0, 1));
|
||||
globalTransform = glm::scale(globalTransform, transform.Scale);
|
||||
transform.Transform = globalTransform;
|
||||
}
|
||||
transform.GlobalTransform = globalTransform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,6 @@ namespace Nuake {
|
||||
float y = wrenGetSlotDouble(vm, 3);
|
||||
float z = wrenGetSlotDouble(vm, 4);
|
||||
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
|
||||
|
||||
auto& cam = ent.GetComponent<CameraComponent>();
|
||||
cam.CameraInstance->SetDirection(Vector3(x, y, z));
|
||||
}
|
||||
|
||||
@@ -266,24 +266,27 @@ namespace Nuake {
|
||||
|
||||
m_Scene->DrawShadows();
|
||||
|
||||
m_Framebuffer->Bind();
|
||||
m_Framebuffer->Clear();
|
||||
{
|
||||
if (Engine::IsPlayMode)
|
||||
m_Scene->Draw();
|
||||
//else
|
||||
// m_Scene->EditorDraw();
|
||||
|
||||
m_Scene->DrawInterface(m_Framebuffer->GetSize());
|
||||
}
|
||||
m_Framebuffer->Unbind();
|
||||
//m_Framebuffer->Bind();
|
||||
//m_Framebuffer->Clear();
|
||||
//{
|
||||
// if (Engine::IsPlayMode)
|
||||
// m_Scene->Draw();
|
||||
// //else
|
||||
// // m_Scene->EditorDraw();
|
||||
//
|
||||
// m_Scene->DrawInterface(m_Framebuffer->GetSize());
|
||||
//}
|
||||
//m_Framebuffer->Unbind();
|
||||
|
||||
|
||||
m_Scene->m_EditorCamera->OnWindowResize(m_GBuffer->GetSize().x, m_GBuffer->GetSize().y);
|
||||
m_GBuffer->Bind();
|
||||
m_GBuffer->Clear();
|
||||
{
|
||||
m_Scene->EditorDrawDeferred();
|
||||
if (Engine::IsPlayMode)
|
||||
m_Scene->DrawDeferred();
|
||||
else
|
||||
m_Scene->EditorDrawDeferred();
|
||||
}
|
||||
|
||||
m_GBuffer->Unbind();
|
||||
@@ -292,10 +295,11 @@ namespace Nuake {
|
||||
m_DeferredBuffer->Clear();
|
||||
{
|
||||
glDisable(GL_CULL_FACE);
|
||||
if (m_Scene->GetEnvironment()->ProceduralSkybox)
|
||||
m_Scene->GetEnvironment()->ProceduralSkybox->Draw(m_Scene->m_EditorCamera);
|
||||
|
||||
m_Scene->EditorDrawDeferredShading();
|
||||
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);
|
||||
@@ -309,8 +313,6 @@ namespace Nuake {
|
||||
deferredShader->SetUniform1i("m_Material", 8);
|
||||
|
||||
Renderer::DrawQuad(Matrix4());
|
||||
|
||||
|
||||
}
|
||||
m_DeferredBuffer->Unbind();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user