mirror of
https://github.com/antopilo/Nuake.git
synced 2026-02-25 14:32:55 +03:00
Compare commits
2 Commits
4aa33b6a20
...
e8e713253e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8e713253e | ||
|
|
6f9f3a96e2 |
Binary file not shown.
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 152 KiB |
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "Nuake/Core/Core.h"
|
#include "Nuake/Core/Core.h"
|
||||||
#include "Nuake/Rendering/Vulkan/SceneViewport.h"
|
#include "Nuake/Rendering/Vulkan/SceneViewport.h"
|
||||||
|
#include "Nuake/Rendering/Vulkan/DebugCmd.h"
|
||||||
|
|
||||||
class CameraPanel
|
class CameraPanel
|
||||||
{
|
{
|
||||||
@@ -22,6 +23,56 @@ public:
|
|||||||
|
|
||||||
previewViewport = vkRenderer.CreateViewport(viewId, { 200, 200 });
|
previewViewport = vkRenderer.CreateViewport(viewId, { 200, 200 });
|
||||||
previewViewport->SetDebugName("CameraPreviewViewport");
|
previewViewport->SetDebugName("CameraPreviewViewport");
|
||||||
|
previewViewport->GetOnDebugDraw().AddStatic([&, componentPtr](DebugCmd& cmd)
|
||||||
|
{
|
||||||
|
Matrix4 transform = Matrix4(1.0f);
|
||||||
|
|
||||||
|
auto& cam = cmd.GetScene()->m_EditorCamera;
|
||||||
|
|
||||||
|
Matrix4 initialTransform = Matrix4(1.0f);
|
||||||
|
initialTransform = glm::translate(initialTransform, cam->Translation);
|
||||||
|
|
||||||
|
Matrix4 gizmoTransform = initialTransform;
|
||||||
|
gizmoTransform = glm::inverse(componentPtr->CameraInstance->GetTransform());
|
||||||
|
gizmoTransform[3] = initialTransform[3];
|
||||||
|
|
||||||
|
auto view = componentPtr->CameraInstance->GetTransform();
|
||||||
|
auto proj = componentPtr->CameraInstance->GetPerspective();
|
||||||
|
|
||||||
|
static auto getGizmoScale = [](const Vector3& camPosition, const Nuake::Vector3& position) -> float
|
||||||
|
{
|
||||||
|
float distance = Distance(camPosition, position);
|
||||||
|
|
||||||
|
constexpr float ClosestDistance = 3.5f;
|
||||||
|
if (distance < ClosestDistance)
|
||||||
|
{
|
||||||
|
float fraction = distance / ClosestDistance;
|
||||||
|
return fraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0f;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector3 cameraPosition = componentPtr->CameraInstance->Translation;
|
||||||
|
|
||||||
|
const Vector3 gizmoSize = Vector3(Engine::GetProject()->Settings.GizmoSize);
|
||||||
|
gizmoTransform = glm::scale(gizmoTransform, gizmoSize * getGizmoScale(cameraPosition, initialTransform[3]));
|
||||||
|
|
||||||
|
cmd.DrawTexturedQuad(proj * view * gizmoTransform, TextureManager::Get()->GetTexture2("Resources/Gizmos/Camera.png"), Engine::GetProject()->Settings.PrimaryColor);
|
||||||
|
});
|
||||||
|
previewViewport->GetOnLineDraw().AddStatic([&, componentPtr](DebugCmd& cmd)
|
||||||
|
{
|
||||||
|
auto& cam = cmd.GetScene()->m_EditorCamera;
|
||||||
|
Matrix4 initialTransform = Matrix4(1.0f);
|
||||||
|
initialTransform = glm::translate(initialTransform, cam->Translation);
|
||||||
|
|
||||||
|
const float aspectRatio = cam->AspectRatio;
|
||||||
|
const float fov = cam->Fov;
|
||||||
|
|
||||||
|
Matrix4 clampedProj = glm::perspectiveFov(glm::radians(fov), 9.0f * aspectRatio, 9.0f, 0.05f, 3.0f);
|
||||||
|
Matrix4 boxTransform = glm::translate(scene->GetCurrentCamera()->GetTransform(), Vector3(transform.GetGlobalTransform()[3])) * rotationMatrix * glm::inverse(clampedProj);
|
||||||
|
lineCmd.DrawBox(proj * boxTransform, Color(1, 0, 0, 1.0f), 1.5f, false);
|
||||||
|
});
|
||||||
|
|
||||||
vkRenderer.RegisterSceneViewport(scene->Shared(), previewViewport->GetID());
|
vkRenderer.RegisterSceneViewport(scene->Shared(), previewViewport->GetID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ BindlessDescriptor::BindlessDescriptor(ResourceType type, BindlessInfo& info)
|
|||||||
{
|
{
|
||||||
const size_t offset = i * size;
|
const size_t offset = i * size;
|
||||||
uint8_t* partitionStart = static_cast<uint8_t*>(mappedData) + offset;
|
uint8_t* partitionStart = static_cast<uint8_t*>(mappedData) + offset;
|
||||||
Descriptors.emplace_back(Descriptor(Buffer, DescriptorLayout, partitionStart, offset, size));
|
Descriptors.emplace_back(Buffer, DescriptorLayout, partitionStart, offset, size, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ namespace Nuake
|
|||||||
~Descriptor() = default;
|
~Descriptor() = default;
|
||||||
|
|
||||||
int32_t LoadResource(const UUID& id);
|
int32_t LoadResource(const UUID& id);
|
||||||
int32_t GetResourceSlot(const UUID& id);
|
int32_t GetResourceSlot(const UUID& id) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Contains buffer for N frames of a resource type
|
// Contains buffer for N frames of a resource type
|
||||||
@@ -98,7 +97,7 @@ namespace Nuake
|
|||||||
{
|
{
|
||||||
Info.ResourceElementSize[T] = sizeof(S);
|
Info.ResourceElementSize[T] = sizeof(S);
|
||||||
Info.ResourceCount[T] = size;
|
Info.ResourceCount[T] = size;
|
||||||
Descriptors[T] = BindlessDescriptor(T, (size_t)sizeof(S) * size);
|
//Descriptors[T] = BindlessDescriptor(T, Info);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ ShadowRenderPipeline::ShadowRenderPipeline()
|
|||||||
shadowPass.SetShaders(shaderMgr.GetShader("shadow_vert"), shaderMgr.GetShader("shadow_frag"));
|
shadowPass.SetShaders(shaderMgr.GetShader("shadow_vert"), shaderMgr.GetShader("shadow_frag"));
|
||||||
shadowPass.SetPushConstant<GBufferConstant>(gbufferConstant);
|
shadowPass.SetPushConstant<GBufferConstant>(gbufferConstant);
|
||||||
shadowPass.SetPreRender([&](PassRenderContext& ctx) {
|
shadowPass.SetPreRender([&](PassRenderContext& ctx) {
|
||||||
auto& layout = ctx.renderPass->PipelineLayout;
|
auto& layout = ctx.renderPass->PipelineLayout;
|
||||||
auto& res = GPUResources::Get();
|
auto& res = GPUResources::Get();
|
||||||
|
|
||||||
Cmd& cmd = ctx.commandBuffer;
|
Cmd& cmd = ctx.commandBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user