Added textured quad to gizmo api

This commit is contained in:
antopilo
2025-03-23 00:06:54 -04:00
parent 8d41c47a93
commit 1e0d79e0eb
5 changed files with 38 additions and 1 deletions

View File

@@ -92,6 +92,7 @@ struct PSOutput {
struct DebugConstant
{
float4x4 Transform;
int TextureID;
};
[[vk::push_constant]]
@@ -101,6 +102,23 @@ PSOutput main(PSInput input)
{
PSOutput output;
if(pushConstants.TextureID < 0)
{
output.oColor0 = float4(input.UV.x, input.UV.y, 0, 1);
}
else
{
float2 uv = input.UV;
float4 textureSample = textures[pushConstants.TextureID].Sample(mySampler, uv);
// Alpha scisorring
if(textureSample.a < 0.1)
{
discard;
}
output.oColor0 = textureSample;
}
return output;
}

View File

@@ -83,6 +83,7 @@ StructuredBuffer<CameraView> cameras;
struct DebugConstant
{
float4x4 Transform;
int TextureID;
};
[[vk::push_constant]]

View File

@@ -6,5 +6,6 @@ namespace Nuake
struct DebugConstant
{
Matrix4 Transform;
int TextureID;
};
}

View File

@@ -1,6 +1,7 @@
#include "DebugCmd.h"
#include "VulkanRenderer.h"
#include "Nuake/Rendering/Vulkan/VkResources.h"
using namespace Nuake;
@@ -17,6 +18,20 @@ DebugCmd::DebugCmd(Cmd& inCmd, PassRenderContext& inCtx) :
void DebugCmd::DrawQuad(const Matrix4& transform)
{
debugConstant.Transform = transform;
debugConstant.TextureID = -1;
cmd.PushConstants(ctx.renderPass->PipelineLayout, sizeof(DebugConstant), &debugConstant);
auto& quadMesh = VkSceneRenderer::QuadMesh;
cmd.BindDescriptorSet(ctx.renderPass->PipelineLayout, quadMesh->GetDescriptorSet(), 1);
cmd.BindIndexBuffer(quadMesh->GetIndexBuffer()->GetBuffer());
cmd.DrawIndexed(6);
}
void DebugCmd::DrawTexturedQuad(const Matrix4& transform, Ref<VulkanImage> texture)
{
debugConstant.Transform = transform;
debugConstant.TextureID = GPUResources::Get().GetBindlessTextureID(texture->GetID());
cmd.PushConstants(ctx.renderPass->PipelineLayout, sizeof(DebugConstant), &debugConstant);
auto& quadMesh = VkSceneRenderer::QuadMesh;

View File

@@ -25,6 +25,8 @@ namespace Nuake
Ref<Scene> GetScene() const;
void DrawQuad(const Matrix4& transform);
void DrawTexturedQuad(const Matrix4& transform, Ref<VulkanImage> texture);
void DrawLine(const Vector3& start, const Vector3& end, const Color& color) const;
void DrawSphere(const Vector2& position, float radius, const Color& color) const;
void DrawCube(const Vector3& position, const Vector3& size, const Color& color) const;