DecalForwardEmissivePass.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. internal class DecalDrawFowardEmissiveSystem : DecalDrawSystem
  5. {
  6. public DecalDrawFowardEmissiveSystem(DecalEntityManager entityManager) : base("DecalDrawFowardEmissiveSystem.Execute", entityManager) { }
  7. protected override int GetPassIndex(DecalCachedChunk decalCachedChunk) => decalCachedChunk.passIndexEmissive;
  8. }
  9. internal class DecalForwardEmissivePass : ScriptableRenderPass
  10. {
  11. private FilteringSettings m_FilteringSettings;
  12. private ProfilingSampler m_ProfilingSampler;
  13. private List<ShaderTagId> m_ShaderTagIdList;
  14. private DecalDrawFowardEmissiveSystem m_DrawSystem;
  15. public DecalForwardEmissivePass(DecalDrawFowardEmissiveSystem drawSystem)
  16. {
  17. renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
  18. ConfigureInput(ScriptableRenderPassInput.Depth); // Require depth
  19. m_DrawSystem = drawSystem;
  20. m_ProfilingSampler = new ProfilingSampler("Decal Forward Emissive Render");
  21. m_FilteringSettings = new FilteringSettings(RenderQueueRange.opaque, -1);
  22. m_ShaderTagIdList = new List<ShaderTagId>();
  23. m_ShaderTagIdList.Add(new ShaderTagId(DecalShaderPassNames.DecalMeshForwardEmissive));
  24. }
  25. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
  26. {
  27. SortingCriteria sortingCriteria = renderingData.cameraData.defaultOpaqueSortFlags;
  28. DrawingSettings drawingSettings = CreateDrawingSettings(m_ShaderTagIdList, ref renderingData, sortingCriteria);
  29. CommandBuffer cmd = CommandBufferPool.Get();
  30. using (new ProfilingScope(cmd, m_ProfilingSampler))
  31. {
  32. context.ExecuteCommandBuffer(cmd);
  33. cmd.Clear();
  34. m_DrawSystem.Execute(cmd);
  35. context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref m_FilteringSettings);
  36. }
  37. context.ExecuteCommandBuffer(cmd);
  38. CommandBufferPool.Release(cmd);
  39. }
  40. }
  41. }