Valid glTF Sampler Filter Flags
In glTF 2.0, texture sampler definitions use WebGL integer constants
to configure magnification (magFilter) and minification
(minFilter) behavior. This guide details the valid numeric
constants, their corresponding OpenGL/WebGL enumerations, and how
mipmapping impacts valid flag selection.
Valid Magnification
Filters (magFilter)
Magnification occurs when a texture pixel (texel) covers more than
one screen pixel. The magFilter property accepts only two
valid integer constants:
- 9728 (
NEAREST): Returns the value of the texture element closest to the specified texture coordinates. This creates a pixelated, sharp look. - 9729 (
LINEAR): Returns the weighted average of the four texture elements closest to the specified texture coordinates. This creates a smoother, blurred appearance.
Mipmapping filters are not valid for magnification because mipmaps are only used when a texture is scaled down.
Valid Minification Filters
(minFilter)
Minification occurs when a texel covers less than one screen pixel.
The minFilter property supports non-mipmapped filtering as
well as mipmapped filtering modes, resulting in six valid integer
constants:
- 9728 (
NEAREST): Selects the closest single texel from the base texture level without using mipmaps. - 9729 (
LINEAR): Calculates a weighted average of the four closest texels from the base texture level without using mipmaps. - 9984 (
NEAREST_MIPMAP_NEAREST): Chooses the closest mipmap level and performs nearest-neighbor sampling within that level. - 9985 (
LINEAR_MIPMAP_NEAREST): Chooses the closest mipmap level and performs bilinear interpolation within that level. - 9986 (
NEAREST_MIPMAP_LINEAR): Performs nearest-neighbor sampling on the two closest mipmap levels and linearly interpolates between the results. - 9987 (
LINEAR_MIPMAP_LINEAR): Performs bilinear filtering on the two closest mipmap levels and linearly interpolates between them (standard trilinear filtering).
Sampler Definition Behavior
Both magFilter and minFilter are optional
within a glTF sampler definition. If omitted, the runtime client
determines the filtering method, typically defaulting to linear
filtering for magnification and trilinear or linear mipmapping for
minification if mipmaps are generated. Specifying any value outside the
defined integer sets violates the glTF 2.0 specification.