27
\$\begingroup\$

I have an assignment due for University, and my task is to discuss textures used within video games, and how they have evolved.

My main question is, what is the fundamental difference between using a sprite, or using other texture methods?

Having done a little research myself, I seem to be inclined that Sprites store images in a single file, and can be used for animations etc.. and were commonly used with older video games, generally using sprites as all of their game visuals. Now, with modern games, sprites I believe tend to be less used as technology advances and other textures are available such as bump mapping. Although sprites are still used today to accommodate features such as a health bar or long distance textures.

But what are the main advantages of using textures, over sprites?

\$\endgroup\$
37
\$\begingroup\$

At the end of the day, sprites and textures are just images - blocks of raster colour data (although sometimes we push the bounds a bit to put non-image data into them). The distinction is largely in how we use them.

We usually call an image (or a part of an image that contains many separate pieces) a "sprite" if its intended rendering purpose is to be drawn straight to the 2D grid of the screen, without perspective distortion. So what you see in the running game is basically what you see in the image file itself (apart from colour tinting/palette swapping/transparency effects). This applies to the background tiles and characters / interactive objects in 2D games, "billboard" cards like particles and older styles of tree & shrub rendering, and also to the user interface elements and icons in 3D games too.

Conversely, if we're using an image to provide surface detail for the polygons of a 3D object that might be drawn in perspective, we usually call that image a "texture." That name has carried over to other uses of image data to modulate rendering of something else, even if they're no longer about texture in the sense you could feel with your fingertips - things like reflections, distortion maps, overlays, masks, or any general-purpose use of images we don't feel like naming more specifically tends to get lumped under "texture" in our loose nomenclature.

That makes the bounds between the two fuzzy and not particularly strict. If I have an image containing a sequence of fire and smoke plumes to use in drawing billboarded particles for an explosion effect, I might call that a "spritesheet" or a "flipbook texture" interchangeably. Or if I have a tileset image comprising all the background tiles for a 2D game, I might call that a "texture atlas" today, by analogy with atlas textures developed for 3D games, even though its data and use in my 2D game is indistinguishable from what someone else would call a spritesheet. If I have a rectangle of geometry whose purpose is to present a single image to the screen, I might call that a "textured quad" or a "sprite" depending on what I want to emphasize about its use.

(Note here in this last example that "sprite" stands for both the source image segment in our game assets, and the instance of a rendered game entity that uses this image segment - another way we use this terminology a bit inconsistently)

You'll find some engines and libraries encode this distinction in rendering intent into their own nomenclature. For instance, in Unity, you can choose to import an image asset as a "Sprite" - this enables an extra set of options that are commonly desired for UI images or 2D game assets, like spritesheet slicing & packing, and the ability to reference parts of the image as discrete entities in your scene and object setup. In these cases "Sprite" often means "an image (texture) plus metadata" - but it's still rendered the same as ordinary textures under the hood. The extra packaging is a convenience so we don't need to micromanage UV offsets and the like everywhere we want to use the image; instead these frameworks conceptually pack that data in as part of the asset entity itself.

\$\endgroup\$
  • \$\begingroup\$ Do "textures" usually include or allow for transparent pixels? I would think of an object which behaves as a pixel-mapped flat surface that contains transparent pixels as a "sprite" whether or not the surface is perpendicular to the camera axis. \$\endgroup\$ – supercat Nov 1 '17 at 20:33
  • 2
    \$\begingroup\$ They certainly can, without giving up their "texture" title. It's common to see folks refer to an image for rendering, say, leaves, or a chain link fence, as a "foliage texture" or "fence texture" even if they're rendered with alpha-test/dithered or alpha-blended transparency. We might also call the leaf case a "foliage sprite" if it's rendered as a camera-facing billboard, but it would be unusual to apply the sprite name if it's used on perspective geometry like a 3D fence. \$\endgroup\$ – DMGregory Nov 1 '17 at 20:41
  • \$\begingroup\$ When rendering opaque texture-mapped objects, a rendering engine need not worry about how the inside of them will appear since the opaque surface will hide the inside. I would think that something like a tree or chain-link fence would be best rendered by doing the opaque portions and then rendering the partially-transparent parts as discrete partially-transparent surfaces. While they might not match what some people would call "sprites" if they don't face the camera, they wouldn't be the same as "normal" objects either. \$\endgroup\$ – supercat Nov 1 '17 at 20:48
  • \$\begingroup\$ That's indeed usually how it's done. The geometry for the fence posts and trunks are rendered in the opaque pass, and then the geometry for the fence spans and foliage/twigs gets rendered in an alpha-test or alpha-blended pass afterward. \$\endgroup\$ – DMGregory Nov 1 '17 at 20:49
  • 1
    \$\begingroup\$ I usually hear "transparent texture" or "alpha texture"/"texture with alpha" — maybe sometimes "cutout"/"cutout texture" if it's a hard-edged/alpha-tested transparency. \$\endgroup\$ – DMGregory Nov 1 '17 at 21:22
7
\$\begingroup\$

A sprite is a relict from the history of computer games. Think 8-bit Ataris around ca. 1980. A little image, usually with a coverage bitmask (or a special "transparent" color) that has a position on the screen and is combined onto the screen in some particular way. With holes where there be "holes" in the sprite, as per the coverage map. Usually in a "just works" way, and in a way that easily allows for the illusion of stuff moving around, usually by saving and restoring the overwritten original screen pixels.

Used to be that sprites were a hardware feature on computers, used to be you could draw/undraw them with screen contents being saved automatically, used to be you could only have a very limited number of them (and non-overlapping, yay!), and used to be that they're pretty darn small (like 16x16) and limited.

The mouse cursor is what comes closest to a sprite nowadays (and used to be it was an actual sprite on some systems until some ~10-15 years ago).

Nowadays, no such thing really exists, but the word remains. A sprite is basically a small 2D image that you draw (composite) somewhere. Usually by drawing a small textured quad.

A texture, on the other hand, is the concept of a readable image used in somewhat more modern graphics APIs. Or, more precisely, a region of memory ("buffer" in terms of modern APIs) with some associated extra data such as size, which can be sampled from via some means. Usually, but not necessarily by a shader running on a graphics processing unit. Usually, but not necessarily, with normalized coordinates, and usually but not necessarily with filtering (and mipmapping, and some particular border mode, and, and, and...).

Thus, a texture may be the source of the data what you use to draw a sprite.

\$\endgroup\$
  • 3
    \$\begingroup\$ Proper sprites are overlaid in hardware, so the video data in memory doesn't change, and doesn't even have to use the same mode (e.g. on the C64, you can have bitmap sprites above a text background). Objects that are rendered by saving the bitmap, and replacing data are called BOBs (Blitter OBjects). \$\endgroup\$ – Simon Richter Nov 2 '17 at 13:30
  • 1
    \$\begingroup\$ @SimonRichter: I'm unfamiliar with the C64, execpt as toy, but the Amiga had those too, 8 of them if I recall correctly. Not sure how it worked on the hardware level, but might as well have been direct overlay (seems likely). On the ST, the A00D/AOOC opcode sprites were certainly of the draw/undraw framebuffer-modifying kind. BOBs, yes, that existed too, typical Amiga thing. That was the closest thing to a present-day texture, I guess (any size, upload to graphics processor once, draw many times). \$\endgroup\$ – Damon Nov 2 '17 at 13:57
4
\$\begingroup\$

It's sortof an apples and oranges comparison. A texture is just an image, while a sprite is an image and how it's used.

We still use sprites for 2d games, and they show up in 3d games in particle effects. Nowadays, sprites generally refer to a certain kind of textured quad, or (rarely, I think) a single triangle. Even UI elements are often still textured quads - which I would call sprites.

It used to be the case that sprites were preloaded into memory and blitted (byte-for-byte mem-copied) to points on screen (literally, screen memory), like stamps. In a way, we still do that. For sprite animations, we often alter the sample coordinates of the source texture to copy segments from textures to be rendered onto quads. Shader effects, such as bump mapping, sample from textures in the same way and thus are still usable for, say, glow effects in sprites.

More particular to 2d games, it's a stylistic choice. One could, for example, compose hand drawn or painted characters in a game using sprites. The South Park games would be an example of that, technically.

So, you can't really use just a texture in place of a sprite.

\$\endgroup\$
3
\$\begingroup\$

Here is a simple and short answer. I usually think of the sprite as the entire object itself alongside whatever functions and textures to have applied to it. As for texture, I pretty much consider it just a image that could be applied to something.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.