Bez popisu
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.

PixelPerfectBackgroundPass.cs 1.3KB

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. // Only to be used when Pixel Perfect Camera is present and it has Crop Frame X or Y enabled.
  5. // This pass simply clears BuiltinRenderTextureType.CameraTarget to black, so that the letterbox or pillarbox is black instead of garbage.
  6. // In the future this can be extended to draw a custom background image instead of just clearing.
  7. internal class PixelPerfectBackgroundPass : ScriptableRenderPass
  8. {
  9. private static readonly ProfilingSampler m_ProfilingScope = new ProfilingSampler("Pixel Perfect Background Pass");
  10. public PixelPerfectBackgroundPass(RenderPassEvent evt)
  11. {
  12. renderPassEvent = evt;
  13. }
  14. [Obsolete(DeprecationMessage.CompatibilityScriptingAPIObsolete, false)]
  15. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
  16. {
  17. var cmd = renderingData.commandBuffer;
  18. using (new ProfilingScope(cmd, m_ProfilingScope))
  19. {
  20. CoreUtils.SetRenderTarget(
  21. cmd,
  22. BuiltinRenderTextureType.CameraTarget,
  23. RenderBufferLoadAction.DontCare,
  24. RenderBufferStoreAction.Store,
  25. ClearFlag.Color,
  26. Color.black);
  27. }
  28. }
  29. }
  30. }