The difference between SpriteRenderer and Image components

  1. Rendering:
    (1) Image is rendered through UGUI's Image and CanvasRenderer components;
    (2) Sprite is rendered through SpriteRenderer components;
    (3) There is no visual difference between the two (when both use the default material). Their default rendering is also in the Transparent Geometry queue.
  2. In principle:
    (1) After the GPU receives the DrawCall command, it generates and renders the final content through a series of processes. The general steps include: a. The CPU
    sends the Draw Call command to the GPU;
    b. The GPU reads the necessary Data to its own video memory;
    c. GPU converts the input geometry information into pixel data through steps such as vertex shader; d
    . Each pixel is processed by fragment shader and written to the frame buffer ;
    e. When all calculations are completed, the GPU displays the frame buffer content on the screen.
    (2) Based on the above knowledge, we can infer:
    a. Sprite has more complex vertex data, so it will be less efficient than Image in the first and second steps of vertex calculation;
    b. Sprite will execute more vertices than Image Shader operations;
    c. Image will perform more fragment shader operations than Sprite;
  3. In use:
    (1) Hierarchy window, you can place the sprite anywhere, and move the sprite like other game objects through Transform; Image must be placed under the Canvas, and can only be moved in the UI interface through RectTransform; (2) Sprite and
    Image One of the most important differences is that sprite supports the automatic construction of the grid, while the grid of UI Image is always composed of rectangles; SpriteRenderer will create additional geometry to crop off redundant transparent pixel areas, thereby reducing a large number of fragment shader operations , and lowered the overdraw. SpriteRenderer is indeed optimized to display more elements. Therefore, in 2D game development, the elements in the game scene should be rendered as much as possible, especially complex geometric images;
    (3) Image is only used for UI display;

Reference article: Unity UGUI series two material SpriteRenderer and Image

おすすめ

転載: blog.csdn.net/weixin_42205218/article/details/126505875