浏览代码

WIP work on semantic filtering

/semantic_shader_tests
Jon Hogins 3 年前
当前提交
724dccd0
共有 7 个文件被更改,包括 30 次插入18 次删除
  1. 9
      com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
  2. 3
      com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat
  3. 2
      com.unity.perception/Runtime/GroundTruth/Labeling/SemanticSegmentationBehaviour.cs
  4. 8
      com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs
  5. 7
      com.unity.perception/Runtime/GroundTruth/RenderPasses/HdrpPasses/SemanticSegmentationPass.cs
  6. 15
      com.unity.perception/Runtime/GroundTruth/Resources/InstanceSegmentation.shader
  7. 4
      com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader

9
com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs


/// </summary>
public SemanticSegmentationLabelConfig labelConfig;
public LayerMask layerMask = ~0;
/// <summary>
/// Event information for <see cref="SemanticSegmentationLabeler.imageReadback"/>
/// </summary>

#if HDRP_PRESENT
var gameObject = perceptionCamera.gameObject;
var customPassVolume = gameObject.GetComponent<CustomPassVolume>() ?? gameObject.AddComponent<CustomPassVolume>();
var gameObjectForVolume = new GameObject();
gameObjectForVolume.transform.parent = gameObject.transform;
gameObjectForVolume.name = "Semantic Segmentation Volume";
var customPassVolume = gameObjectForVolume.AddComponent<CustomPassVolume>();
m_SemanticSegmentationPass = new SemanticSegmentationPass(myCamera, targetTexture, labelConfig)
m_SemanticSegmentationPass = new SemanticSegmentationPass(myCamera, targetTexture, labelConfig, layerMask)
{
name = "Labeling Pass"
};

3
com.unity.perception/Runtime/GroundTruth/Labelers/Visualization/Materials/SegmentationMaterial.mat


m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 1
- _BackTransparency: 0
- _BackTransparency: 0.78313255
- _Blend: 2
- _BlendOp: 0
- _BumpScale: 1

- _ReplaceColor: {r: 1, g: 1, b: 1, a: 0}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []
--- !u!114 &3089368426582508830
MonoBehaviour:
m_ObjectHideFlags: 11

2
com.unity.perception/Runtime/GroundTruth/Labeling/SemanticSegmentationBehaviour.cs


//public bool enableTransparency = false;
//public float opacityThreshold = 1;
public bool useSegmentationMask;
public Texture2D segmentationMask;
public Texture segmentationMask;
public bool useMainTextureAsSegmask = false;
}

8
com.unity.perception/Runtime/GroundTruth/RenderPasses/CrossPipelinePasses/SemanticSegmentationCrossPipelinePass.cs


// [SerializeField]
Shader m_ClassLabelingShader;
Material m_OverrideMaterial;
LayerMask m_LayerMask;
public SemanticSegmentationCrossPipelinePass(
Camera targetCamera, SemanticSegmentationLabelConfig labelConfig) : base(targetCamera)
public SemanticSegmentationCrossPipelinePass(Camera targetCamera, SemanticSegmentationLabelConfig labelConfig,
LayerMask layerMask) : base(targetCamera)
m_LayerMask = layerMask;
}
public override void Setup()

return;
s_LastFrameExecuted = Time.frameCount;
var renderList = CreateRendererListDesc(camera, cullingResult, "FirstPass", 0, m_OverrideMaterial, -1);
var renderList = CreateRendererListDesc(camera, cullingResult, "FirstPass", 0, m_OverrideMaterial, m_LayerMask);
cmd.ClearRenderTarget(true, true, m_LabelConfig.skyColor);
DrawRendererList(renderContext, cmd, RendererList.Create(renderList));
}

7
com.unity.perception/Runtime/GroundTruth/RenderPasses/HdrpPasses/SemanticSegmentationPass.cs


public Camera targetCamera;
SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass;
private LayerMask layerMask;
public SemanticSegmentationPass(Camera targetCamera, RenderTexture targetTexture, SemanticSegmentationLabelConfig semanticSegmentationLabelConfig)
public SemanticSegmentationPass(Camera targetCamera, RenderTexture targetTexture,
SemanticSegmentationLabelConfig semanticSegmentationLabelConfig, LayerMask layerMask)
this.layerMask = layerMask;
EnsureInit();
}

{
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(targetCamera, semanticSegmentationLabelConfig);
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(targetCamera, semanticSegmentationLabelConfig, layerMask);
m_SemanticSegmentationCrossPipelinePass.EnsureActivated();
}
}

15
com.unity.perception/Runtime/GroundTruth/Resources/InstanceSegmentation.shader


#include "UnityCG.cginc"
#include "Packing.hlsl"
sampler2D _MainTex;
Texture2D _MainTex;
SamplerState s_point_clamp_sampler;
struct appdata
{

fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
fixed4 col = _MainTex.Sample(s_point_clamp_sampler, i.uv);
if (col.r == 0 && col.g == 0 && col.b == 0)
{
outColor = fixed4(0,0,0,1);
}
return outColor;
// if (col.r == 0 && col.g == 0 && col.b == 0)
// {
// outColor = fixed4(0,0,0,1);
// }
return col;
}
// float opacity = 1 * _BaseColor.a;

4
com.unity.perception/Runtime/GroundTruth/Resources/SemanticSegmentation.shader


if (_TextureIsSegmentationMask == 1)
{
if (col.r == 0 && col.g == 0 && col.b == 0)
outColor = fixed4(0,0,0,1);
col = fixed4(0,0,0,1);
return outColor;
return col;
}
// //float opacity = col.a * _BaseColor.a;

正在加载...
取消
保存