Anatomy of a sprite

spritegrid
Example of an object on its tile.
Blue chair image courtesy of PJ at SimFreaks
The original tile grid is from The Bunny Wuffles School of Sims Transmogrification

The relationship between a sprite and the tile it sits on is more complicated than one might think. This image shows a blue chair p-sprite within its bounding box (yellow) within a larger frame (pale yellow), sitting on a tile (outlined in red).

The larger frame has a predefined size of 136 x 384 pixels. The size and position of the bounding box is defined within the SPR2 resource, in the frame header, and may or may not leave some space around the visible sprite image.

Alpha channel

The game will draw the entire contents of the bounding box, using the alpha channel to mask out any unneeded pixels. In most cases the yellow background of the p-sprite image is transparent because the underlying alpha channel value is zero. Alpha channel sprites exported by TMog are black when the alpha channel is zero, and grey when the alpha channel is greater than zero. If the alpha channel is grey then the object is partially transparent (used for anti-aliased edges and semi-transparent panels). If the alpha channel is white then the sprite pixel will be opaque in game.

IFFSnooper uses this convention when exporting sprites as "Tmog view" and when assembling sprite images into a new SPR2 resource.

Z-buffer

The Z-buffer will determine how close or far the sprite pixel appears to be, relative to the front and back walls of the imaginary prism which rises from the tile. Z-buffers will be discussed in more detail later.

DGRP offset

Although the SPR2 resource tells the game what to draw on the tile, it does not indicate where on the tile to draw it. That information is found in the DGRP resource, which provides pixelx and pixely offsets from the centre of the tile. The DGRP coordinate axes are drawn in blue, and the pixelx, pixely starting point is indicated by the blue dot.


Putting together a multisprite drawgroup

This example uses the Maxis file showertubunleashed.iff, which has one opaque sprite per tile for the tub base and one translucent sprite per tile for the water level.

Aligning the water level sprite with the tub sprite.
Showertub 1
In this first example the translucent water level is aligned with the tub base according to the DGRP resource coordinates.

Taking into account the Z buffers.
Showertub 2
Next the sprite Z buffer data is used to determine which parts of the tub are in front of the water in this view.

Taking into account the alpha channels.
Showertub 3
Finally the sprite alpha channel data is used to correctly render the translucent water layer by blending the water p-sprite data with the underlying p-sprite data for the tub wall.



Navigation

introduction

What are these resources?

Making new IFF files

Making Floor Tiles

Making Walls

Editing OBJD resources

Editing the GUID

Editing text strings

Editing draw groups

Editing sprites

Editing menu resources

Editing other resources