better outline + gizmo interaction

This commit is contained in:
antopilo
2025-04-14 17:29:23 -04:00
parent 5ce9fb6093
commit 57564645f2
8 changed files with 98 additions and 74 deletions

View File

@@ -87,6 +87,7 @@ struct PSInput {
struct PSOutput {
float4 oColor0 : SV_TARGET;
float4 oEntityID : SV_TARGET1;
};
struct DebugConstant
@@ -94,6 +95,7 @@ struct DebugConstant
float4 Color;
float4x4 Transform;
int TextureID;
float EntityID;
};
[[vk::push_constant]]
@@ -102,7 +104,7 @@ DebugConstant pushConstants;
PSOutput main(PSInput input)
{
PSOutput output;
if(pushConstants.TextureID < 0)
{
output.oColor0 = float4(input.UV.x, input.UV.y, 0, 1);
@@ -115,10 +117,26 @@ PSOutput main(PSInput input)
// Alpha scisorring
if(textureSample.a < 0.1)
{
discard;
//discard;
}
output.oColor0 = textureSample * pushConstants.Color;
if(pushConstants.EntityID != 0.0f)
{
float2 center = float2(0.5, 0.5);
float dist = distance(uv, center);
float radius = 0.5; // You can adjust this as needed
if (dist <= radius)
{
output.oEntityID = float4(pushConstants.EntityID, 0, 0, 1.0f);
}
else
{
output.oEntityID = float4(0, 0, 0, 0); // Or leave it unassigned if default is zero
}
}
}
return output;

View File

@@ -85,6 +85,7 @@ struct DebugConstant
float4 Color;
float4x4 Transform;
int TextureID;
float EntityID;
};
[[vk::push_constant]]

View File

@@ -122,6 +122,7 @@ PSOutput main(PSInput input)
float hasHit = 0.0f;
float sampleValue = textures[entityIDTextureID].Sample(mySampler, uv).r;
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler, uv).r;
float4 fragColor = float4(0, 0, 0, 0);
const float TAU = 6.28318530;
@@ -135,7 +136,8 @@ PSOutput main(PSInput input)
sampleUV.y = clamp(sampleUV.y, 0.0, 0.999);
float sample = textures[entityIDTextureID].Sample(mySampler, sampleUV).r;
if(sample == target)
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler, sampleUV).r;
if(sample == target && sampleDepth != 1.0f && sampleDepth > depth)
{
hasHit = 1.0f;
}