mirror of
https://github.com/antopilo/Nuake.git
synced 2026-01-06 06:09:52 +03:00
Added textured quad to gizmo api
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -83,6 +83,7 @@ StructuredBuffer<CameraView> cameras;
|
||||
struct DebugConstant
|
||||
{
|
||||
float4x4 Transform;
|
||||
int TextureID;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
|
||||
@@ -6,5 +6,6 @@ namespace Nuake
|
||||
struct DebugConstant
|
||||
{
|
||||
Matrix4 Transform;
|
||||
int TextureID;
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user