Skip to content

Latest commit

 

History

History
117 lines (63 loc) · 7.89 KB

Unity-Graphics-Sprites-Textures.md

File metadata and controls

117 lines (63 loc) · 7.89 KB

Reference Sheet - Graphics > Sprites and Textures

Table of Contents

Terms

Term Definition
Texture Any bitmap image in Unity. Can be added to a scene directly by setting its mode to sprite, or by placing it on a Material and attaching it to a 3D object.
Sprite A bitmap image that can be used directly in a (usually 2D) game. Can be repositioned, scaled, and rotated like any other game object in Unity. All Sprites in your Scene contain at least the Transform and Sprite Renderer components.
Sprite Renderer The component that renders 2D sprites and controls how they appear in the scene. The Sprite property of a SpriteRenderer determines which sprite will be shown in the game and can be manipulated in code.
Sprite Sheet A texture (bitmap image) containing multiple, smaller images, usually frame-by-frame animations, for 2D games. By packing multiple files into a single texture it reduces the number of images that must be drawn in each frame (a.k.a. "draw calls") thus increasing performance. View examples.
Texture Atlas A texture (bitmap image) containing multiple, smaller images, usually tileable textures for walls and other environmental components for 3D games. Essentially the same as a sprite sheet but used in different contexts. View examples.
Lossy When a file is compressed and data is lost (i.e. it loses quality). Lossless is when every single bit of data remains. Lossy compression results in smaller file sizes but again, with a loss in quality.
Pixels Per Unit (PPU) Pixels per unit is a sprite import setting that determines the relationship between pixels (the image scale) and Unity's units. For pixel art you typically use a low PPU, allowing you to easily snap tiles together in a scene, while you want a higher PPU for high resolution graphics. The default is 100.

Power of 2

Ideally, Texture dimension sizes should be powers of two on each side. This ensures hardware can efficiently compress images in your game, decreasing required memory thus increasing overall performance. The Textures do not have to be square; that is the width can be different from height.

Power 21 22 23 24 25 26 27 28 29 210 211 212
Pixels 2 4 8 16 32 64 128 256 512 1024 2048 4096

Unity image formats

Type Lossless Alpha Description
PNG Commonly used on the web. Lossless compression; has an alpha channel.
JPG Commonly used on the web. Lossy compression; no alpha channel.
GIF Commonly used on the web. Lossy compression; no alpha channel.
BMP Default image format on Windows. No compression; no alpha channel.
TGA Commonly used for 3D graphics; obscure everywhere else. No or lossless compression; has an alpha channel.
TIFF Commonly used for digital photography and publishing. No or lossless compression; no alpha channel.
PICT Default image format on old Macs. Lossy compression; no alpha channel.
PSD Native file format for Photoshop. No compression; has an alpha channel. The main reason to use this file format would be the advantage of using Photoshop files directly.

Sprites

Terms

Term Definition
Sprite Tags Tags help you identify GameObjects for scripting purposes. For example, you might define “Player” Tags for player-controlled characters or items the player can collect in a Scene with a “Collectable” Tag.
Sprite Sorting Layers Sorting Layers and Order in Layer are used by the Sprite Renderer to determine the render order of sprites in a scene. You can add and arrange Sorting Layers, and change the order of sprites in the layer (both positive and negative values) to affect how sprites overlay. See this video for a demonstration.
Layers Layers are most commonly used by Cameras and Lights to render or illuminate only parts of the scene. They can also be used by raycasting to selectively ignore colliders or to create collisions. If you want to change the overlay of Sprites you should use Sorting Layers (above).

Tools

Tool Description
Sprite Editor A tool for slicing sprite sheets into individual sprites. To use it set Texture Type to Sprite and Sprite Mode to Multiple in the Inspector.
Sprite Creator A tool for creating temporary placeholder sprites you can use in your project during development.
Sprite Packer A tool in Unity to pack individual sprites and increase the performance of your game.

Textures

Terms

Term Definition
UV mapping Projecting a 2D image onto a 3D model's surface mapping using UV coordinates. Think about it as either "wrapping" a 3D model with a texture (e.g. 🎁 ), or "unwrapping" or "unfolding" a 3D model to lay it flat onto a 2D texture. See also: Intro to UV Mapping video
UV coordinates The coordinates (U,V) that control where a texture is positioned on an unwrapped 3D model. The letters (U,V) denote the axes of the 2D texture because (X,Y,Z) are already used to denote the axes of the 3D object in model space.
Bump map A special kind of texture that adds surface detail. Normal maps can represent fine surface detail much more efficiently than using additional polygons.
Normal map A type of bump map that adds surface detail such as bumps, grooves, and scratches to a model which catch the light as if they are represented by real geometry.
Height map A greyscale Texture that stores height data for an object. Each pixel stores the height difference perpendicular to the face that pixel represents.
Surface normals The vector (a.k.a. "normal") representing a line perpendicular to the angle of an object's surface relative to the light.

uv map

A character texture atlas, and its corresponding normal map texture atlas

Sources

  • Unity Manual and Unity Scripting Reference
  • Chapter 2 in Ferro, Lauren S., and Francesco Sapio. Unity 2017 Game Development. Packt, 2018.
  • Chapter 4 in Hocking, Joseph. Unity in Action: Multiplatform Game Development in C # (2nd Edition). Manning, 2018.
  • Chapter 1 in Godbold, Ashley, and Simon Jackson. Mastering Unity 2D Game Development (2nd Edition). Packt, 2016.
  • Chapter 3 in Halpern, Jared. Developing 2D Games with Unity. APress, 2019.