Texture files

The terms texture and sprite often get confused in game development, so it's worth making the distinction: a texture is simply an image file, a big list of color data telling the interpreting program what color each pixel of the image should be, whereas a sprite can be seen as the 2D equivalent of a mesh—it defines how and where the image will appear in the game scene. Usually, a sprite is just a single quad (a pair of triangles combined to make a rectangular mesh) that renders flat against the current camera.

There are also things called sprite sheets, which are large collections of individual images contained within a larger texture file, commonly used to contain the animations of a 2D character. These files can be split apart by tools, such as Unity's Sprite Atlas tool, to form individual textures for the character's animated frames.

Of course, you can render a 2D sprite in a 3D environment; however, in essence, a sprite is still a 2D element in the same way a playing card is still a flat card, even when it is used to build a house of cards.

Both meshes and sprites use textures to render an image onto its surface. Texture image files are typically generated in tools such as Adobe Photoshop or GIMP and then imported into our project in much the same way as audio files. At runtime, these files are loaded into memory, pushed to the GPU's VRAM, and rendered by a shader over the target sprite or mesh during a given draw call.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.189.177