DeferredPass.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine.Experimental.GlobalIllumination;
  2. using UnityEngine.Profiling;
  3. using Unity.Collections;
  4. // cleanup code
  5. // listMinDepth and maxDepth should be stored in a different uniform block?
  6. // Point lights stored as vec4
  7. // RelLightIndices should be stored in ushort instead of uint.
  8. // TODO use Unity.Mathematics
  9. // TODO Check if there is a bitarray structure (with dynamic size) available in Unity
  10. namespace UnityEngine.Rendering.Universal.Internal
  11. {
  12. // Render all tiled-based deferred lights.
  13. internal class DeferredPass : ScriptableRenderPass
  14. {
  15. DeferredLights m_DeferredLights;
  16. public DeferredPass(RenderPassEvent evt, DeferredLights deferredLights)
  17. {
  18. base.profilingSampler = new ProfilingSampler(nameof(DeferredPass));
  19. base.renderPassEvent = evt;
  20. m_DeferredLights = deferredLights;
  21. }
  22. // ScriptableRenderPass
  23. public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescripor)
  24. {
  25. RenderTargetIdentifier lightingAttachmentId = m_DeferredLights.GbufferAttachmentIdentifiers[m_DeferredLights.GBufferLightingIndex];
  26. RenderTargetIdentifier depthAttachmentId = m_DeferredLights.DepthAttachmentIdentifier;
  27. if (m_DeferredLights.UseRenderPass)
  28. ConfigureInputAttachments(m_DeferredLights.DeferredInputAttachments, m_DeferredLights.DeferredInputIsTransient);
  29. // TODO: change to m_DeferredLights.GetGBufferFormat(m_DeferredLights.GBufferLightingIndex) when it's not GraphicsFormat.None
  30. // TODO: Cannot currently bind depth texture as read-only!
  31. ConfigureTarget(lightingAttachmentId, depthAttachmentId, cameraTextureDescripor.graphicsFormat);
  32. }
  33. // ScriptableRenderPass
  34. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
  35. {
  36. m_DeferredLights.ExecuteDeferredPass(context, ref renderingData);
  37. }
  38. // ScriptableRenderPass
  39. public override void OnCameraCleanup(CommandBuffer cmd)
  40. {
  41. m_DeferredLights.OnCameraCleanup(cmd);
  42. }
  43. }
  44. }