Skip to main content

Function: computeGridLevels()

computeGridLevels(baseResolution, levels, mipsPerLevel?): number[]

Computes the per-level grid resolutions for a genuine (paper-style) mip pyramid: baseResolution is the finest (mip 0) level's resolution, and each subsequent stored feature level is mipsPerLevel mip-halvings coarser than the previous one - e.g. computeGridLevels(128, 3, 2) -> [128, 32, 8] (each level a quarter the resolution of the last, i.e. 2 halvings apart). This is deliberately not a 1:1 grid-level-per-mip-level mapping - see NTCMipBands.js's selectFeatureLevel, which maps a continuous/discrete target LOD down onto one of these (far fewer) stored levels, exactly like the NVIDIA neural texture compression paper's Table 1 (a handful of feature levels, each reused via the decoder's LOD input to reconstruct several physical mips - see that file's doc comment for how this reproduces the paper's actual storage-compression mechanism).

Level 0 (index 0, the array's first entry) is always the finest/base resolution. baseResolution is clamped to [1, MAX_GRID_RESOLUTION] and rounded to the nearest integer; levels and mipsPerLevel are each clamped to >= 1 and rounded.

Parameters​

baseResolution​

number

levels​

number

mipsPerLevel?​

number = DEFAULT_MIPS_PER_LEVEL

Returns​

number[]