Skip to content

Sprite Shapes

Narta Xaymar Dirks edited this page Oct 28, 2026 · 2 revisions

Sprite shapes

A sprite is a square, but a flame, a puff of smoke or a drop of water fills only part of it, and the rest is see-through pixels that still cost time to draw. When a texture is loaded (or written to between LockBuffer and UnlockBuffer) with flag 2 (alpha) or 4 (masked), BlitzLLVM finds the smallest octagon (a square with its corners cut off) that has every visible pixel in it, with some room for texture filtering. Every sprite that uses the texture draws that octagon, whose pixels outside the octagon would have been see-through anyway. For a round texture it is about 17% less area to fill, and sprites with the same texture share one shape, so they are drawn in far fewer draw calls.

The square is kept when the texture fills most of it, has no alpha or mask, has frames (LoadAnimTexture), was drawn on with the drawing commands or is a movie, has been scaled, moved or turned (ScaleTexture, PositionTexture, RotateTexture), has other texture layers, or is a sphere or cube map. A sprite that covers fewer than 128 pixels on the screen also keeps the square: the GPU fills blocks of pixels, so two big triangles are cheaper than six tiny ones, and the blur of the small mip levels cannot show a cut edge. Textures with mip maps (flag 8) get a little more room around the octagon for the same blur. The environment variable BLITZLLVM_SPRITE_HULL=0 turns the shapes off, which is useful to compare the pictures.

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally