Skip to content

GraphicsOrderIndependentTransparency

Narta Xaymar Dirks edited this page Oct 31, 2026 · 1 revision

GraphicsOrderIndependentTransparency

GraphicsOrderIndependentTransparency:Void enable:Int32
Parameter Mode Type Default Description
enable In Int32 required 0 (False) to sort by distance, 1 (True) to add up in any order with weights, 2 for the moment based kind, 3 for the sorted samples of a pixel with the weighted tail (4 samples), 4 the same with 8 samples, 5 for the exact reference by depth peeling.

Description

Turns order-independent transparency on or off. It is off by default, and this is a BlitzLLVM extension: the original sorts see-through entities by their distance (as BlitzLLVM does with it off), which shows when see-through things cross each other or are bigger than they look (leaves in front of a window, smoke sprites that overlap), and the order is wrong for some of the pixels. With it on, everything that is blended (the blend modes alpha, multiply and add of EntityBlend, and the layers of textures that blend) is not drawn into the picture in order but added up in four images whose sums do not depend on the order, and one pass over the picture then puts the sums on it: first everything blended by alpha, then the multiplied, then the added.

The alpha is weighted blended order-independent transparency (McGuire and Bavoil, 2013): the colors of all layers at a pixel are averaged with weights that favor the layers that are near (by the place of their entity among the see-through ones, which are sorted by distance, so entities at the same distance count the same, and a pixel that is nearer or farther than the origin of its entity counts by how much, so that entities that pass through one another are weighed per pixel), and the opacity is that of all layers together. That is approximate: it is what the layers look like on average, not exactly what the order of the original draws makes, so a picture can differ from the original where layers cross, and a layer that is nearly solid in front of another one shows less of the one behind than it would in the original. Multiply and add are the same sums as in the original (they do not depend on the order). Entities with an EntityOrder other than 0 are still drawn in order, see-through things are still tested against the depth of what is solid and do not write to it, and fading sprites (SpriteDepthFade) work as before. Dither 2 does not blend in the shader while this is on (the sums are half floats and are added to the picture without noise).

With 2 it is moment based order-independent transparency (Munstermann et al., 2018): see-through things are drawn twice, first to sums of their optical depth and its first four powers of the depth, then with the color of each layer weighted by how much light gets through what the sums say is in front of it. That tells layers apart by their depth and not by their order, so it is closer to the original where many layers cross, and it needs more images and a second pass over the see-through geometry.

With 3 (4 samples per pixel) or 4 (8 samples) it is hybrid transparency in the samples of a pixel: the see-through things are drawn into a multisampled picture where each fragment takes one sample (picked by noise) and the depth test of the samples keeps the nearest fragment of each, so a pixel keeps up to 4 (or 8) layers that are sorted by depth and blended in that order exactly. All layers are also added up as with 1, and what the samples hold is taken out of those sums again, so the layers that did not fit (the further ones, or those that landed in the same sample) are blended behind as their average color. That makes the nearest layers exact, which the average cannot do, but costs the multisampled images, a 32 bit sum and both passes over the see-through things. Where the driver has no 8 samples, 4 are used.

With 5 the see-through things are drawn by depth peeling: once for each layer (up to the number in the environment variable BLITZLLVM_OIT_LAYERS, 128 if it is not set), from the farthest layer at each pixel to the nearest, and each layer is blended into a float image that is put on the picture once. That is the exact order of the layers at every pixel (equal depths excepted) and without the rounding of 8 bits for every layer, so it is the picture the other kinds are measured against, but it draws everything see-through as many times as there are layers and is meant for reference pictures and not for playing. Multiply and add are not drawn with it.

It costs four more images the size of the picture (28 bytes per pixel, 44 with 2, and 3 and 4 add the samples: about 40 bytes per sample) for each size of picture that is drawn to, and a pass over the picture for each blend mode that was used. It takes effect with the next picture. HWOrderIndependentTransparency says whether it is available; the environment variable BLITZLLVM_OIT=1 (or 2, 3, 4, 5) does the same without the command.

Related Commands

DitherMode, DitherTemporal, HWOrderIndependentTransparency, TransparencyDistanceSortMode

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally