PostProcessPassCompat.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. namespace UnityEngine.Rendering.Universal
  2. {
  3. internal class PostProcessPassCompat : ScriptableRenderPass
  4. {
  5. RenderTargetHandle m_Source;
  6. RenderTargetHandle m_Destination;
  7. RenderTextureDescriptor m_Descriptor;
  8. RenderTargetHandle m_TemporaryColorTexture;
  9. bool m_IsOpaquePostProcessing;
  10. const string k_RenderPostProcessingTag = "Render PostProcessing Effects (Compat)";
  11. public PostProcessPassCompat(RenderPassEvent evt, bool renderOpaques = false)
  12. {
  13. m_IsOpaquePostProcessing = renderOpaques;
  14. m_TemporaryColorTexture.Init("_TemporaryColorTexture");
  15. renderPassEvent = evt;
  16. }
  17. public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle sourceHandle, RenderTargetHandle destinationHandle)
  18. {
  19. m_Descriptor = baseDescriptor;
  20. m_Source = sourceHandle;
  21. m_Destination = destinationHandle;
  22. }
  23. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
  24. {
  25. #if POST_PROCESSING_STACK_2_0_0_OR_NEWER
  26. #pragma warning disable 0618 // Obsolete
  27. ref CameraData cameraData = ref renderingData.cameraData;
  28. bool isLastRenderPass = (m_Destination == RenderTargetHandle.CameraTarget);
  29. bool flip = isLastRenderPass && cameraData.camera.targetTexture == null;
  30. CommandBuffer cmd = CommandBufferPool.Get(k_RenderPostProcessingTag);
  31. RenderPostProcessing(cmd, ref renderingData.cameraData, m_Descriptor, m_Source.Identifier(),
  32. m_Destination.Identifier(), m_IsOpaquePostProcessing, flip);
  33. context.ExecuteCommandBuffer(cmd);
  34. CommandBufferPool.Release(cmd);
  35. #pragma warning restore 0618
  36. #endif
  37. }
  38. }
  39. }