NewRendererFeature.cs.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine;
  2. using UnityEngine.Rendering;
  3. using UnityEngine.Rendering.Universal;
  4. public class #SCRIPTNAME# : ScriptableRendererFeature
  5. {
  6. class CustomRenderPass : ScriptableRenderPass
  7. {
  8. // This method is called before executing the render pass.
  9. // It can be used to configure render targets and their clear state. Also to create temporary render target textures.
  10. // When empty this render pass will render to the active camera render target.
  11. // You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
  12. // The render pipeline will ensure target setup and clearing happens in a performant manner.
  13. public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
  14. {
  15. }
  16. // Here you can implement the rendering logic.
  17. // Use <c>ScriptableRenderContext</c> to issue drawing commands or execute command buffers
  18. // https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.html
  19. // You don't have to call ScriptableRenderContext.submit, the render pipeline will call it at specific points in the pipeline.
  20. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
  21. {
  22. }
  23. // Cleanup any allocated resources that were created during the execution of this render pass.
  24. public override void OnCameraCleanup(CommandBuffer cmd)
  25. {
  26. }
  27. }
  28. CustomRenderPass m_ScriptablePass;
  29. /// <inheritdoc/>
  30. public override void Create()
  31. {
  32. m_ScriptablePass = new CustomRenderPass();
  33. // Configures where the render pass should be injected.
  34. m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
  35. }
  36. // Here you can inject one or multiple render passes in the renderer.
  37. // This method is called when setting up the renderer once per-camera.
  38. public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
  39. {
  40. renderer.EnqueuePass(m_ScriptablePass);
  41. }
  42. }