SPR: Difference between revisions
Jump to navigation
Jump to search
Warning:All frames in a multi-frame sprite share the same palette.
Bug:Oriented sprites are finicky; see The303's tutorials for more information. [todo tested in ?]
Bug:Sprites being displayed via env_glow cannot be oriented in the map editor. If rotation is necessary, use env_sprite instead. [todo tested in ?]
SirYodaJedi (talk | contribs) No edit summary |
Robotboy655 (talk | contribs) (added binary data format info) |
||
Line 36: | Line 36: | ||
| Facing Upright || Like parallel upright, but rotated based on player origin, rather than camera. | | Facing Upright || Like parallel upright, but rotated based on player origin, rather than camera. | ||
|} | |} | ||
== Data format == | |||
=== Header === | |||
<source lang="cpp">struct sprite | |||
{ | |||
int id; // format ID, "IDSP" (0x49 0x44 0x53 0x50) | |||
int version; // Format version number, such as 2 (0x02,0x00,0x00,0x00) | |||
int spriteType; | |||
int textFormat; | |||
float boundingRadius; | |||
int maxWidth; | |||
int maxHeight; | |||
int frameNum; // number of frames the sprite contains | |||
float beamLength; | |||
int synchType; | |||
short paletteColorCount; // number of colors in the palette | |||
}; | |||
</source> | |||
=== Palette === | |||
After the header, comes a list of palette colors of "paletteColorCount" size, each one 3 bytes - Red, Green, Blue. | |||
=== Frames === | |||
After that come the sprite frames. (frameNum from the header) | |||
<source lang="cpp">struct sprite_frame_header | |||
{ | |||
int group; | |||
int originX; // not sure about this one, it always huge for sprites in HL1 | |||
int originY; | |||
int width; | |||
int height; | |||
// Right after this, the paletted image data comes, each byte is a pixel. | |||
// The image size is given in the frame header, so the entire data for 1 frame is width*height bytes. | |||
}; | |||
</source> | |||
== External links == | == External links == |
Revision as of 16:04, 15 October 2024
.SPR is a file format used to store 2D sprites in GoldSrc. It is a modified version of the SPR format used by
Quake, adding a dedicated color palette and additional translucency formats (Quake SPRs only support alphatest transparency).
Limitations



Image format types
Format | Explanation |
---|---|
Normal | Opaque image with no transparency |
Additive | Same as Normal; Additive translucency can be achieved for any image format by changing the sprite's rendermode (either in a sprite entity, or via code) |
IndexAlpha | Single-color with 8-bit translucency |
AlphaTest | Binary alpha-tested transparency; pixels using the last color in the palette will be transparent |
Orientation types
Orientation | Explaination |
---|---|
Parallel | Rotates to always face the camera |
Parallel Upright | Like parallel, but doesn't rotate around Z axis |
Oriented | Rotated in map editor to face a specific direction |
Parallel Oriented | Combination of parallel and oriented. |
Facing Upright | Like parallel upright, but rotated based on player origin, rather than camera. |
Data format
Header
struct sprite
{
int id; // format ID, "IDSP" (0x49 0x44 0x53 0x50)
int version; // Format version number, such as 2 (0x02,0x00,0x00,0x00)
int spriteType;
int textFormat;
float boundingRadius;
int maxWidth;
int maxHeight;
int frameNum; // number of frames the sprite contains
float beamLength;
int synchType;
short paletteColorCount; // number of colors in the palette
};
Palette
After the header, comes a list of palette colors of "paletteColorCount" size, each one 3 bytes - Red, Green, Blue.
Frames
After that come the sprite frames. (frameNum from the header)
struct sprite_frame_header
{
int group;
int originX; // not sure about this one, it always huge for sprites in HL1
int originY;
int width;
int height;
// Right after this, the paletted image data comes, each byte is a pixel.
// The image size is given in the frame header, so the entire data for 1 frame is width*height bytes.
};