Skip to content

Compositing modes

ModeAlgorithmUse Case
DVRFront-to-back alpha compositing with transfer functionGeneral visualization
MIPMaximum intensity along rayAngiography, vessel detection
ISOFirst surface at threshold + Phong shadingSurface extraction
LODColor-coded by resolution levelDebug LOD distribution
SliceThree orthogonal planes sampling the atlas directlyAnatomical navigation

DVR compositing uses the optical model with extinction:

wgsl
fn composeSample(density, stepSize, color, alpha) {
    let tfColor = textureSample(transferFunction, density);
    let extinction = tfColor.a * stepSize * volumeScale;
    let sampleAlpha = 1.0 - exp(-extinction);

    // Front-to-back blending
    *color += tfColor.rgb * sampleAlpha * (1.0 - *alpha);
    *alpha += sampleAlpha * (1.0 - *alpha);
}

Multichannel compositing

For multichannel datasets (up to 4 channels), the rendering pipeline switches from transfer-function-based compositing to additive per-channel blending. Each channel is sampled from its own atlas texture, windowed independently, and coloured with a user-defined colour. The weighted contributions are summed:

wgsl
// Per-channel: sample atlas, apply windowing, weight by channel colour
for (var ch = 0u; ch < numChannels; ch++) {
    let density = sampleAtlas(atlasTextures[ch], ...);
    let windowed = applyWindow(density, channelCenter[ch], channelWidth[ch]);
    channelColor += channelColors[ch].rgb * windowed * channelColors[ch].a;
    maxDensity = max(maxDensity, windowed);
}

// Composite the additive result into the ray
composeSampleAdditive(channelColor, maxDensity, ...);

The composeSampleAdditive function normalises the summed colour by the maximum density to avoid over-brightening, then applies front-to-back compositing (DVR) or tracks per-channel maximums (MIP).

Transfer functions are not used in multichannel mode. See Multichannel for per-mode behaviour and API details.