Difference between sprite and texture?
Asked Answered
Y

2

22

Can you please explain the difference between texture and sprite? When we zoom in a sprite, it appears blurry because it's basically an image. Is it the same for a texture?

I read this comment on the image below online:

The background layers are textures and not sprites.

enter image description here

Can someone explain?

Yonder answered 3/1, 2016 at 10:59 Comment(0)
L
18

Sprites and Textures are both images.

A Sprite is an image that can be used as a 2d object, which have coordinates (x, y) and which you can move, destroy or create during the game.

A Texture is also an image, but that will be used to change the appearence of an object. E.g. you can set a texture for the faces of a cube, a layer (like the background) or even a sprite. But as texture are not objects, you can't move them during the game.

Laryngology answered 3/1, 2016 at 11:7 Comment(3)
What's the advantage of using a texture instead of a sprite in a layer?Yonder
I think that it's because the texture is something static so it would require less computer resources than a spriteLaryngology
There is no advantage in using texture over sprite for a 2d game. You 'd better use all in Sprite. The Sprite rendering system is optimised since it knows up front there won't be any 3d shape to consider. Only the layer system is taken care and since it is just one integer, it goes real fast. Also, I would think it only needs to be updated if the user changes the values, so the sprite is bagged in a collection of items with same layer at the beginning. Texture with a quad are considered 3d and requires depth buffer for each vertex despite the fact you are using a flat item.Return
W
9

Sprite is the image that is moving related to static images (for example background). Sprites are usually planes (rectangles) with texture on it. Sprites are used in 3D graphics for tricks such as Billboard or Impostor. In 2D games sprites are used instead of moving objects and also as backgrounds.

Texture is an raster image that is to be projected on polygonal object. It worth using textures each time when using polygons is expensive for given objects details (for example bullet dots)

Winkle answered 3/1, 2016 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.