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

73 行
2.5 KiB

#if HDRP_PRESENT
using System;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
namespace UnityEngine.Perception.GroundTruth
{
abstract class GroundTruthPass : CustomPass, IGroundTruthGenerator
{
public Camera targetCamera;
bool m_IsActivated;
public abstract void SetupMaterialProperties(
MaterialPropertyBlock mpb, Renderer meshRenderer, Labeling labeling, uint instanceId);
public abstract void ClearMaterialProperties(
MaterialPropertyBlock mpb, Renderer meshRenderer, Labeling labeling, uint instanceId);
protected GroundTruthPass(Camera targetCamera)
{
this.targetCamera = targetCamera;
}
protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
{
if (targetCamera == null)
throw new InvalidOperationException("targetCamera may not be null");
// If we are forced to activate here we will get zeroes in the first frame.
EnsureActivated();
targetColorBuffer = TargetBuffer.Custom;
targetDepthBuffer = TargetBuffer.Custom;
}
//overrides obsolete member in HDRP on 2020.1+. Re-address when removing 2019.4 support or the API is dropped
#if HDRP_9_OR_NEWER
protected override void Execute(CustomPassContext ctx)
{
ScriptableRenderContext renderContext = ctx.renderContext;
var cmd = ctx.cmd;
var hdCamera = ctx.hdCamera;
var cullingResult = ctx.cullingResults;
#else
protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult)
{
#endif
// CustomPasses are executed for each camera. We only want to run for the target camera
if (hdCamera.camera != targetCamera)
return;
ExecutePass(renderContext, cmd, hdCamera, cullingResult);
}
protected abstract void ExecutePass(
ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera hdCamera, CullingResults cullingResult);
protected void EnsureActivated()
{
if (!m_IsActivated)
{
LabelManager.singleton.Activate(this);
m_IsActivated = true;
}
}
protected override void Cleanup()
{
LabelManager.singleton.Deactivate(this);
}
}
}
#endif