From 9a26fd75ca469c34c73067d0e6d5649b20d8be54 Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Mon, 13 Nov 2023 13:23:16 +0100 Subject: [PATCH] Why isnt this working.... --- res/shaders/LegacyBasePass.slang | 7 +++---- res/shaders/lib/MaterialParameter.slang | 3 ++- src/Engine/Component/Camera.cpp | 3 +-- src/Engine/Component/Camera.h | 2 +- src/Engine/Graphics/VertexData.cpp | 2 +- src/Engine/Graphics/Vulkan/Resources.cpp | 1 - 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/res/shaders/LegacyBasePass.slang b/res/shaders/LegacyBasePass.slang index 9fb1f60..8f8e38b 100644 --- a/res/shaders/LegacyBasePass.slang +++ b/res/shaders/LegacyBasePass.slang @@ -15,12 +15,11 @@ layout(set=2) ParameterBlock pScene; [shader("vertex")] -void vertexMain( +FragmentParameter vertexMain( uint vertexId: SV_VertexID, uint instanceId: SV_InstanceID, - out FragmentParameter params: PARAMETER, -){ +) : PARAMETER{ InstanceData inst = pScene.instances[instanceId]; VertexAttributes attr = pVertexData.getAttributes(vertexId, inst.transformMatrix); - params = attr.getParameter(inst.transformMatrix); + return attr.getParameter(inst.transformMatrix); } \ No newline at end of file diff --git a/res/shaders/lib/MaterialParameter.slang b/res/shaders/lib/MaterialParameter.slang index 98740a2..c77ac8e 100644 --- a/res/shaders/lib/MaterialParameter.slang +++ b/res/shaders/lib/MaterialParameter.slang @@ -20,13 +20,14 @@ struct LightingParameter // data passed to fragment shader struct FragmentParameter { + // clip position has to be the first attribute for some reason???? + float4 position_CS : SV_Position; float3 position_TS; float3 viewDir_TS; float3 normal_WS; float3 tangent_WS; float3 biTangent_WS; float3 position_WS; - float4 position_CS : SV_Position; float2 texCoords; float3 vertexColor; MaterialParameter getMaterialParameter() diff --git a/src/Engine/Component/Camera.cpp b/src/Engine/Component/Camera.cpp index f6cf937..63c7b4b 100644 --- a/src/Engine/Component/Camera.cpp +++ b/src/Engine/Component/Camera.cpp @@ -54,8 +54,7 @@ void Camera::buildViewMatrix() { Vector eyePos = getTransform().getPosition();//getAbsoluteTransform().getPosition(); Vector lookAt = eyePos + glm::normalize(Vector(cos(yaw) * cos(pitch), sin(pitch), sin(yaw) * cos(pitch))); - //std::cout << "Eye: " << eyePos << " lookAt: " << lookAt << std::endl; - viewMatrix = glm::lookAt(Vector(100, 0, 10), Vector(0, 0, 0), Vector(0, 1, 0));//glm::lookAt(eyePos, lookAt, Vector(0, 1, 0)); + viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0)); bNeedsViewBuild = false; } diff --git a/src/Engine/Component/Camera.h b/src/Engine/Component/Camera.h index ce3921c..f3401ba 100644 --- a/src/Engine/Component/Camera.h +++ b/src/Engine/Component/Camera.h @@ -32,7 +32,7 @@ struct Camera //Transforms relative to actor float yaw; float pitch; - bool mainCamera = true; + bool mainCamera = false; private: bool bNeedsViewBuild; }; diff --git a/src/Engine/Graphics/VertexData.cpp b/src/Engine/Graphics/VertexData.cpp index d180a9c..9f30742 100644 --- a/src/Engine/Graphics/VertexData.cpp +++ b/src/Engine/Graphics/VertexData.cpp @@ -29,7 +29,7 @@ void VertexData::updateMesh(const Component::Transform& transform, PMesh mesh) matInstanceData.meshes.add(MeshInstanceData{ .id = mesh->id, .instance = InstanceData { - .transformMatrix = Matrix4(1),//transform.toMatrix(), + .transformMatrix = transform.toMatrix(), }, .indexBuffer = mesh->indexBuffer, }); diff --git a/src/Engine/Graphics/Vulkan/Resources.cpp b/src/Engine/Graphics/Vulkan/Resources.cpp index fc34a6c..3266f08 100644 --- a/src/Engine/Graphics/Vulkan/Resources.cpp +++ b/src/Engine/Graphics/Vulkan/Resources.cpp @@ -16,7 +16,6 @@ Semaphore::Semaphore(PGraphics graphics) Semaphore::~Semaphore() { - graphics = nullptr; vkDestroySemaphore(graphics->getDevice(), handle, nullptr); }