Guest User

CopyDepthRenderFeature

a guest
Apr 13th, 2021
73
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Rendering;
  5. using UnityEngine.Rendering.Universal;
  6. using UnityEngine.Rendering.Universal.Internal;
  7.  
  8. public class CopyDepthRenderFeature : ScriptableRendererFeature
  9. {
  10.     CopyDepthPass _pass;
  11.     RenderTargetHandle _depthDestHandle;
  12.     RenderTargetHandle _depthSourceHandle;
  13.  
  14.     public RenderPassEvent renderPassEvent;
  15.  
  16.     public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
  17.     {
  18.         _pass.Setup(_depthSourceHandle, _depthDestHandle);
  19.         renderer.EnqueuePass(_pass);
  20.     }
  21.  
  22.     public override void Create()
  23.     {
  24.         if (_pass != null)
  25.         {
  26.             _pass = null;
  27.         }
  28.  
  29.         _pass = new CopyDepthPass(renderPassEvent, CoreUtils.CreateEngineMaterial("Hidden/Universal Render Pipeline/CopyDepth"));
  30.         _depthSourceHandle = new RenderTargetHandle();
  31.         _depthDestHandle = new RenderTargetHandle();
  32.  
  33.         _depthSourceHandle.Init("_CameraDepthAttachment");
  34.         _depthDestHandle.Init("_CameraDepthTexture");
  35.     }
  36. }
RAW Paste Data