No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DBufferDepthCopyPass.cs 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using UnityEngine.Experimental.Rendering;
  2. using UnityEngine.Rendering.RenderGraphModule;
  3. using UnityEngine.Rendering.Universal.Internal;
  4. namespace UnityEngine.Rendering.Universal
  5. {
  6. /// <summary>
  7. /// Used by DBuffer to copy depth into different texture.
  8. /// In future this should be replaced by proper depth copy logic, as current CopyDepthPass do not implement RecordRenderGraph.
  9. /// </summary>
  10. internal class DBufferCopyDepthPass : CopyDepthPass
  11. {
  12. public DBufferCopyDepthPass(RenderPassEvent evt, Shader copyDepthShader, bool shouldClear = false, bool copyToDepth = false, bool copyResolvedDepth = false)
  13. : base(evt, copyDepthShader, shouldClear, copyToDepth, copyResolvedDepth)
  14. {
  15. }
  16. public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
  17. {
  18. UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
  19. UniversalCameraData cameraData = frameData.Get<UniversalCameraData>();
  20. UniversalRenderer renderer = (UniversalRenderer)cameraData.renderer;
  21. TextureHandle cameraDepthTexture = resourceData.cameraDepthTexture;
  22. TextureHandle src, dest;
  23. if (renderer.renderingModeActual == RenderingMode.Deferred)
  24. {
  25. src = resourceData.activeDepthTexture;
  26. dest = cameraDepthTexture;
  27. }
  28. else
  29. {
  30. var depthDesc = cameraData.cameraTargetDescriptor;
  31. depthDesc.graphicsFormat = GraphicsFormat.None; //Depth only rendering
  32. depthDesc.depthStencilFormat = cameraData.cameraTargetDescriptor.depthStencilFormat;
  33. depthDesc.msaaSamples = 1;
  34. var depthTarget = UniversalRenderer.CreateRenderGraphTexture(renderGraph, depthDesc, DBufferRenderPass.s_DBufferDepthName, true);
  35. resourceData.dBufferDepth = depthTarget;
  36. src = cameraDepthTexture;
  37. dest = cameraData.cameraTargetDescriptor.msaaSamples > 1 ? depthTarget : resourceData.activeDepthTexture;
  38. }
  39. Render(renderGraph, dest, src, resourceData, cameraData, false);
  40. }
  41. }
  42. }