您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

46 行
1.8 KiB

#if HDRP_PRESENT
using System;
using JetBrains.Annotations;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Rendering;
namespace UnityEngine.Perception.GroundTruth
{
/// <summary>
/// A CustomPass for creating object instance segmentation images. GameObjects containing Labeling components
/// are assigned unique IDs, which are rendered into the target texture.
/// </summary>
public class InstanceSegmentationPass : CustomPass
{
InstanceSegmentationCrossPipelinePass m_InstanceSegmentationCrossPipelinePass;
public RenderTexture targetTexture;
public Camera targetCamera;
[UsedImplicitly]
public InstanceSegmentationPass() {}
protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult)
{
CoreUtils.SetRenderTarget(cmd, targetTexture, ClearFlag.All);
m_InstanceSegmentationCrossPipelinePass.Execute(renderContext, cmd, hdCamera.camera, cullingResult);
}
public void EnsureInit()
{
if (m_InstanceSegmentationCrossPipelinePass == null)
{
m_InstanceSegmentationCrossPipelinePass = new InstanceSegmentationCrossPipelinePass(targetCamera);
m_InstanceSegmentationCrossPipelinePass.Setup();
}
}
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
{
base.Setup(renderContext, cmd);
Debug.Assert(m_InstanceSegmentationCrossPipelinePass != null, "InstanceSegmentationPass.EnsureInit() should be called before the first camera render to get proper object labels in the first frame");
EnsureInit();
}
}
}
#endif