Jon Hogins
4 年前
当前提交
904ff3db
共有 9 个文件被更改,包括 377 次插入 和 482 次删除
-
2TestProjects/PerceptionHDRP/Assets/Prefabs/KeypointCube.prefab
-
481TestProjects/PerceptionHDRP/Assets/Scenes/SampleScene.unity
-
160com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs
-
83com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheck.shader
-
3com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheck.shader.meta
-
102com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheckHDRP.shader
-
3com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthCheckHDRP.shader.meta
-
17com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthTest.compute
-
8com.unity.perception/Runtime/GroundTruth/Resources/KeypointDepthTest.compute.meta
|
|||
Shader "Perception/KeypointDepthCheck" |
|||
{ |
|||
Properties |
|||
{ |
|||
_Positions("Positions", 2D) = "defaultTexture" {} |
|||
_KeypointDepth("KeypointDepth", 2D) = "defaultTexture" {} |
|||
_DepthTexture("Depth", 2DArray) = "defaultTexture" {} |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch |
|||
|
|||
//enable GPU instancing support |
|||
#pragma multi_compile_instancing |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags { "RenderType"="Opaque" } |
|||
LOD 100 |
|||
|
|||
Pass |
|||
{ |
|||
Tags { "LightMode" = "SRP" } |
|||
|
|||
Blend Off |
|||
ZWrite On |
|||
ZTest LEqual |
|||
|
|||
Cull Back |
|||
|
|||
CGPROGRAM |
|||
|
|||
#pragma vertex depthCheckVertexStage |
|||
#pragma fragment depthCheckFragmentStage |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
UNITY_DECLARE_TEX2DARRAY(_DepthTexture); |
|||
//sampler2D _CameraDepthTexture; |
|||
|
|||
Texture2D _Positions; |
|||
SamplerState my_point_clamp_sampler; |
|||
Texture2D _KeypointDepth; |
|||
|
|||
struct in_vert |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
struct vertexToFragment |
|||
{ |
|||
float4 vertex : SV_POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
vertexToFragment depthCheckVertexStage (in_vert vertWorldSpace) |
|||
{ |
|||
vertexToFragment vertScreenSpace; |
|||
vertScreenSpace.vertex = UnityObjectToClipPos(vertWorldSpace.vertex); |
|||
vertScreenSpace.uv = vertWorldSpace.uv; |
|||
return vertScreenSpace; |
|||
} |
|||
|
|||
fixed4 depthCheckFragmentStage (vertexToFragment vertScreenSpace) : SV_Target |
|||
{ |
|||
float4 checkPosition = _Positions.Sample(my_point_clamp_sampler, vertScreenSpace.uv); |
|||
float4 checkDepth = _KeypointDepth.Sample(my_point_clamp_sampler, vertScreenSpace.uv); |
|||
float depth = UNITY_SAMPLE_TEX2DARRAY(_DepthTexture, float3(checkPosition.xy, 0)).r; //SAMPLE_DEPTH_TEXTURE(_DepthTexture, checkPosition.xy); |
|||
//float depth_decoded = LinearEyeDepth(depth); |
|||
float depth_decoded = Linear01Depth(depth); |
|||
uint result = depth_decoded < checkDepth.x - .001 ? 0 : 1; |
|||
return fixed4(result, result, result, result); |
|||
} |
|||
|
|||
ENDCG |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5fd132f5a09c4301b4c9004b241e2659 |
|||
timeCreated: 1618585131 |
|
|||
Shader "Perception/KeypointDepthCheck" |
|||
{ |
|||
Properties |
|||
{ |
|||
_Positions("Positions", 2D) = "defaultTexture" {} |
|||
_KeypointDepth("KeypointDepth", 2D) = "defaultTexture" {} |
|||
_DepthTexture("Depth", 2DArray) = "defaultTexture" {} |
|||
} |
|||
|
|||
HLSLINCLUDE |
|||
|
|||
#pragma target 4.5 |
|||
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch |
|||
|
|||
//enable GPU instancing support |
|||
#pragma multi_compile_instancing |
|||
|
|||
ENDHLSL |
|||
|
|||
SubShader |
|||
{ |
|||
Tags{ "RenderPipeline" = "HDRenderPipeline" } |
|||
Pass |
|||
{ |
|||
Tags { "LightMode" = "SRP" } |
|||
|
|||
Name "KeypointDepthCheck" |
|||
ZWrite Off |
|||
ZTest Always |
|||
Blend SrcAlpha OneMinusSrcAlpha |
|||
Cull Off |
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma multi_compile HDRP_DISABLED HDRP_ENABLED |
|||
#pragma only_renderers d3d11 vulkan metal |
|||
#pragma target 4.5 |
|||
#pragma vertex Vert |
|||
#pragma fragment FullScreenPass |
|||
|
|||
|
|||
//UNITY_DECLARE_TEX2DARRAY(_DepthTexture); |
|||
//sampler2D _CameraDepthTexture; |
|||
|
|||
Texture2D _Positions; |
|||
SamplerState my_point_clamp_sampler; |
|||
Texture2D _KeypointDepth; |
|||
|
|||
#if HDRP_ENABLED |
|||
|
|||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl" |
|||
|
|||
float4 FullScreenPass(Varyings varyings) : SV_Target |
|||
{ |
|||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varyings); |
|||
|
|||
float4 checkPosition = _Positions.Load(float3(varyings.positionCS.xy, 0)); |
|||
float4 checkDepth = _KeypointDepth.Load(float3(varyings.positionCS.xy, 0)); |
|||
|
|||
float depth = LoadCameraDepth(checkPosition.xy); |
|||
depth = LinearEyeDepth(depth, _ZBufferParams); |
|||
// float depth = UNITY_SAMPLE_TEX2DARRAY(_DepthTexture, float3(checkPosition.xy, 0)).r; //SAMPLE_DEPTH_TEXTURE(_DepthTexture, checkPosition.xy); |
|||
//float depth_decoded = LinearEyeDepth(depth); |
|||
// float depth_decoded = Linear01Depth(depth); |
|||
uint result = depth < checkDepth.x - .001 ? 0 : 1; |
|||
return float4(result, result, result, result); |
|||
} |
|||
#else |
|||
/// Dummy Implementation for non HDRP_ENABLED variants |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
struct appdata |
|||
{ |
|||
float4 vertex : POSITION; |
|||
float2 uv : TEXCOORD0; |
|||
}; |
|||
|
|||
struct v2f |
|||
{ |
|||
float2 uv : TEXCOORD0; |
|||
float4 vertex : SV_POSITION; |
|||
}; |
|||
|
|||
v2f Vert(appdata v) |
|||
{ |
|||
v2f o; |
|||
o.uv = float2(0, 0); |
|||
o.vertex = float4(0, 0, 0, 0); |
|||
return o; |
|||
} |
|||
|
|||
float4 FullScreenPass(v2f i) : SV_Target |
|||
{ |
|||
return float4(0, 0, 0, 1); |
|||
} |
|||
#endif |
|||
ENDHLSL |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9940b8b9f40d48b5bf942d679dbd9d5d |
|||
timeCreated: 1618629386 |
|
|||
// Each #kernel tells which function to compile; you can have many kernels |
|||
#pragma kernel CSMain |
|||
|
|||
// Create a RenderTexture with enableRandomWrite flag and set it |
|||
// with cs.SetTexture |
|||
|
|||
StructuredBuffer<float3> CheckPositions; |
|||
Texture3D<float4> DepthBuffer; |
|||
RWStructuredBuffer<uint> CheckResults; |
|||
|
|||
[numthreads(16,1,1)] |
|||
void CSMain (uint3 id : SV_DispatchThreadID) |
|||
{ |
|||
float3 checkPosition = CheckPositions[id.x]; |
|||
uint result = DepthBuffer[float3(checkPosition.x, checkPosition.y, 0)] < checkPosition.z - .001 ? 0 : 1; |
|||
CheckResults[id.x] = result; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c78354f07f15bac48977fc60cc5082c9 |
|||
ComputeShaderImporter: |
|||
externalObjects: {} |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue