Search Unity

Resolved How are off-screen pixels handled?

Discussion in 'General Graphics' started by Lo-renzo, Oct 8, 2020.

  1. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    I have a sprite (simple quad) that covers the whole screen for applying weather effects. Should I be resizing this sprite so that it only exceeds the bounds of the (orthographic) camera by a little bit? Or are these off-screen pixels pruned efficiently by default?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,338
    As far as rendering performance is concerned, it's mostly irrelevant if the quad is exactly the same size as the view bounds, or 1000 times larger. If it covers the entire screen it's going to be essentially the same rendering cost. Any surface of a quad not seen isn't costing any extra at that point.

    However the area of the sprite not seen by the camera are still there, and still taking memory, both in the project and on the GPU. Whether or not this is an issue depend on if you see it as one or not, and how much memory you're using elsewhere. As far as the GPU is concerned, as long as your game isn't going to make GPUs run out of memory, it's a non-issue. If this is a 2048x2048 uncompressed texture that you're only ever viewing a smaller 1920x1080 part of, then yes, maybe you should be cropping it down to just the area that's ever visible just to reduce the build size. Or use it with Unity Sprite Atlas system so other sprites can be packed into the unused space of the 2048x2048 atlas texture it generates anyway.
     
    Lo-renzo likes this.