浏览代码

Add search for non-background pixel to keypoint depth check. Not perfect, but catches a few edge cases for now. Should migrate to doing all checks in shader at some point

/keypoint_self_occlusion
Jon Hogins 3 年前
当前提交
540b2aab
共有 2 个文件被更改,包括 41 次插入14 次删除
  1. 51
      com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheck.shader
  2. 4
      com.unity.perception/Tests/Runtime/GroundTruthTests/KeypointGroundTruthTests.cs

51
com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheck.shader


#pragma vertex Vert
#pragma fragment Frag
#if HDRP_ENABLED
#pragma enable_d3d11_debug_symbols
static const float2 checkOffsets[9] = {
float2( 0, 0),
float2(-1, -1),
float2( 0, -1),
float2( 1, -1),
float2(-1, 0),
float2( 1, 0),
float2(-1, 1),
float2( 0, 1),
float2( 1, 1)};
SamplerState my_point_clamp_sampler;
#if HDRP_ENABLED
#pragma enable_d3d11_debug_symbols
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl"
float4 Frag(Varyings varyings) : SV_Target

float4 checkPosition = _Positions.Load(float3(varyings.positionCS.xy, 0));
float depth = LoadCameraDepth(float2(checkPosition.x, _ScreenSize.y - checkPosition.y));
float2 checkPosition = _Positions.Load(float3(varyings.positionCS.xy, 0)).xy;
checkPosition = float2(checkPosition.x, _ScreenSize.y - checkPosition.y);
float2 checkPositionResolved;
float depth;
for (int i = 0; i < 9; i++)
{
checkPositionResolved = checkPosition + checkOffsets[i];
depth = LoadCameraDepth(checkPositionResolved);
if (depth > 0)
break;
}
PositionInputs positionInputs = GetPositionInput(checkPosition, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
depth = positionInputs.linearDepth;

#else
#include "UnityCG.cginc"
Texture2D _Positions;
SamplerState my_point_clamp_sampler;
Texture2D _KeypointCheckDepth;
//copied from UnityInput.hlsl
float4x4 _InvViewProjMatrix;

}
fixed4 Frag (v2f i) : SV_Target
{
float4 checkPosition = _Positions.Load(float3(i.vertex.xy, 0));
float depth = LoadSceneDepth(float2(checkPosition.x, _ScreenParams.y - checkPosition.y));
float2 checkPosition = _Positions.Load(float3(i.vertex.xy, 0)).xy;
checkPosition = float2(checkPosition.x, _ScreenParams.y - checkPosition.y);
float2 checkPositionResolved;
float depth;
for (int i = 0; i < 9; i++)
{
checkPositionResolved = checkPosition + checkOffsets[i];
depth = LoadSceneDepth(checkPositionResolved);
if (depth > 0)
break;
}
float depthVSActual = ViewSpaceDepth(depth);
uint result = depthVSActual >= depthVSToCheck ? 1 : 0;

4
com.unity.perception/Tests/Runtime/GroundTruthTests/KeypointGroundTruthTests.cs


AddTestObjectForCleanup(cam);
TestHelper.LoadAndStartRenderDocCapture();
//TestHelper.LoadAndStartRenderDocCapture();
yield return null;
PlaceObjects(new Rect(0, 0, 4, 4), 0, new Vector2Int(25, 25));

DestroyTestObject(cam);
texture.Release();
TestHelper.EndCaptureRenderDoc();
//TestHelper.EndCaptureRenderDoc();
Assert.AreEqual(2, incoming.Count);

正在加载...
取消
保存