您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
31 行
1.4 KiB
31 行
1.4 KiB
using UnityEngine.Rendering;
|
|
|
|
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
|
|
{
|
|
public class SceneViewDepthCopyPass : ScriptableRenderPass
|
|
{
|
|
const string k_CopyDepthToCameraTag = "Copy Depth to Camera";
|
|
|
|
private RenderTargetHandle source { get; set; }
|
|
|
|
public void Setup(RenderTargetHandle source)
|
|
{
|
|
this.source = source;
|
|
}
|
|
|
|
public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
|
|
{
|
|
// Restore Render target for additional editor rendering.
|
|
// Note: Scene view camera always perform depth prepass
|
|
CommandBuffer cmd = CommandBufferPool.Get(k_CopyDepthToCameraTag);
|
|
CoreUtils.SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget);
|
|
cmd.SetGlobalTexture("_CameraDepthAttachment", source.Identifier());
|
|
cmd.EnableShaderKeyword(LightweightKeywordStrings.DepthNoMsaa);
|
|
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa2);
|
|
cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa4);
|
|
cmd.Blit(source.Identifier(), BuiltinRenderTextureType.CameraTarget, renderer.GetMaterial(MaterialHandles.DepthCopy));
|
|
context.ExecuteCommandBuffer(cmd);
|
|
CommandBufferPool.Release(cmd);
|
|
}
|
|
}
|
|
}
|