NewRendererFeature.cs.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 an performance manner.
  13. public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
  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 FrameCleanup(CommandBuffer cmd)
  25. {
  26. }
  27. }
  28. CustomRenderPass m_ScriptablePass;
  29. public override void Create()
  30. {
  31. m_ScriptablePass = new CustomRenderPass();
  32. // Configures where the render pass should be injected.
  33. m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
  34. }
  35. // Here you can inject one or multiple render passes in the renderer.
  36. // This method is called when setting up the renderer once per-camera.
  37. public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
  38. {
  39. renderer.EnqueuePass(m_ScriptablePass);
  40. }
  41. }