mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Progress towards working selection outline
This commit is contained in:
@@ -102,6 +102,13 @@ struct OutlinePushConstant
|
||||
[[vk::push_constant]]
|
||||
OutlinePushConstant pushConstants;
|
||||
|
||||
float2 GetTexelSize(Texture2D tex)
|
||||
{
|
||||
uint width, height;
|
||||
tex.GetDimensions(width, height);
|
||||
return 1.0 / float2(width, height);
|
||||
}
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
PSOutput output;
|
||||
@@ -116,31 +123,24 @@ PSOutput main(PSInput input)
|
||||
|
||||
float sampleValue = textures[entityIDTextureID].Sample(mySampler, uv).r;
|
||||
|
||||
if(abs(sampleValue - target) < 0.0001)
|
||||
{
|
||||
output.oColor0 = outlineColor;
|
||||
output.oColor0.a = 1.0;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 fragColor = float4(0, 0, 0, 0);
|
||||
const float TAU = 6.28318530;
|
||||
const float steps = 32.0;
|
||||
for(float i = 0.0f; i < TAU; i += TAU / steps)
|
||||
{
|
||||
float2 uvOffset = float2(sin(i), cos(i)) * radius;
|
||||
float2 uvOffset = float2(sin(i), cos(i)) * (GetTexelSize(textures[entityIDTextureID])) * radius;
|
||||
|
||||
float2 sampleUV = uv + uvOffset;
|
||||
sampleUV.x = clamp(sampleUV.x, 0.0, 0.999);
|
||||
sampleUV.y = clamp(sampleUV.y, 0.0, 0.999);
|
||||
|
||||
int sampleValue = (int)textures[entityIDTextureID].Sample(mySampler, sampleUV).r;
|
||||
if(sampleValue == target)
|
||||
float sample = textures[entityIDTextureID].Sample(mySampler, sampleUV).r;
|
||||
if(sample == target)
|
||||
{
|
||||
hasHit = 1.0f;
|
||||
}
|
||||
|
||||
float alpha = smoothstep(0.5, 0.9, int(sampleValue != target) * hasHit * 10.0f);
|
||||
float alpha = smoothstep(0.5, 0.9, hasHit);
|
||||
float4 outputColor = float4(
|
||||
lerp(fragColor.r, outlineColor.r, alpha),
|
||||
lerp(fragColor.g, outlineColor.g, alpha),
|
||||
@@ -156,6 +156,15 @@ PSOutput main(PSInput input)
|
||||
fragColor.a = 1.0f;
|
||||
}
|
||||
|
||||
output.oColor0 = fragColor;
|
||||
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler, uv).rgb;
|
||||
float ratio = float(sampleValue != target && hasHit > 0.0f);
|
||||
float4 finalColor = float4(
|
||||
lerp(sourceTexture.r, fragColor.r, ratio),
|
||||
lerp(sourceTexture.g, fragColor.g, ratio),
|
||||
lerp(sourceTexture.b, fragColor.b, ratio),
|
||||
lerp(1.0f, fragColor.a, ratio)
|
||||
);
|
||||
|
||||
output.oColor0 = finalColor;
|
||||
return output;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ PSOutput main(PSInput input)
|
||||
|
||||
output.oMaterial = float4(materialOuput, 1.0f);
|
||||
|
||||
output.oEntityID = float4(pushConstants.entityID, pushConstants.entityID, pushConstants.entityID, pushConstants.entityID);
|
||||
output.oEntityID = float4(pushConstants.entityID, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user