Guest User

ScriptableRenderFeature

a guest
Aug 27th, 2019
625
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine.Rendering;
  2. using UnityEngine.Rendering.Universal;
  3.  
  4. public class DepthNormalsFeature : ScriptableRendererFeature
  5. {
  6. private DepthNormalsPass depthNormalsPass;
  7.  
  8. RenderTargetHandle m_DepthNormalsTexture;
  9.  
  10. public override void Create()
  11. {
  12. if (depthNormalsPass == null)
  13. depthNormalsPass =
  14. new DepthNormalsPass(RenderPassEvent.BeforeRenderingPrepasses, RenderQueueRange.opaque, -1);
  15.  
  16. m_DepthNormalsTexture.Init("_CameraDepthNormalsTexture");
  17. }
  18.  
  19. public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
  20. {
  21. depthNormalsPass.Setup(renderingData.cameraData.cameraTargetDescriptor, m_DepthNormalsTexture);
  22. renderer.EnqueuePass(depthNormalsPass);
  23. }
  24.  
  25. void OnValidate()
  26. {
  27. depthNormalsPass?.SetLayerMask(-1);
  28. }
  29. }
RAW Paste Data