您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
55 行
1.9 KiB
55 行
1.9 KiB
#if HDRP_PRESENT
|
|
|
|
using System;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Rendering.HighDefinition;
|
|
|
|
namespace UnityEngine.Perception.Sensors
|
|
{
|
|
/// <summary>
|
|
/// Custom Pass which renders labeled images where each object with a Labeling component is drawn with the value
|
|
/// specified by the given LabelingConfiguration.
|
|
/// </summary>
|
|
public class SemanticSegmentationPass : CustomPass
|
|
{
|
|
public RenderTexture targetTexture;
|
|
public LabelingConfiguration labelingConfiguration;
|
|
public Camera targetCamera;
|
|
|
|
SemanticSegmentationCrossPipelinePass m_SemanticSegmentationCrossPipelinePass;
|
|
|
|
public SemanticSegmentationPass(Camera targetCamera, RenderTexture targetTexture, LabelingConfiguration labelingConfiguration)
|
|
{
|
|
this.targetTexture = targetTexture;
|
|
this.labelingConfiguration = labelingConfiguration;
|
|
this.targetCamera = targetCamera;
|
|
EnsureInit();
|
|
}
|
|
|
|
void EnsureInit()
|
|
{
|
|
if (m_SemanticSegmentationCrossPipelinePass == null)
|
|
{
|
|
m_SemanticSegmentationCrossPipelinePass = new SemanticSegmentationCrossPipelinePass(targetCamera, labelingConfiguration);
|
|
m_SemanticSegmentationCrossPipelinePass.EnsureActivated();
|
|
}
|
|
}
|
|
|
|
public SemanticSegmentationPass()
|
|
{
|
|
}
|
|
|
|
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
|
|
{
|
|
EnsureInit();
|
|
m_SemanticSegmentationCrossPipelinePass.Setup();
|
|
}
|
|
|
|
protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult)
|
|
{
|
|
CoreUtils.SetRenderTarget(cmd, targetTexture, ClearFlag.All);
|
|
m_SemanticSegmentationCrossPipelinePass.Execute(renderContext, cmd, hdCamera.camera, cullingResult);
|
|
}
|
|
}
|
|
}
|
|
#endif
|