[][src]Enum web_glitz::sampler::MinificationFilter

pub enum MinificationFilter {
    Nearest,
    Linear,
    NearestMipmapNearest,
    NearestMipmapLinear,
    LinearMipmapNearest,
    LinearMipmapLinear,
}

Enumerates the methods available to a Sampler for minification filtering.

Minification filtering is used when a sampling a texture value for a fragment that is larger than the candidate texels.

Minification Filtering and Mipmapping

Some of the filtering methods involve mipmapping. When a fragment is larger than the candidate texels, the fragment surface might span multiple texels. The most appropriate sample value might then be obtained by interpolating between these texels. However, doing this for each sampling operation can be very expensive.

This is instead solved by using a mipmap, which produces similar results with much better performance. A mipmap is a pre-calculated sequence of images, starting with the original image. Each subsequent image is half the width and half the height of the previous image (rounded down). The sequence ends when the width or height reaches 1. Each image in the mipmap sequence is identified by a mipmap level: the base image has a mipmap level of 0, the subsequent image has a mipmap level of 1, etc. For example, a mipmap of a base image of size 256 by 256 has 9 mipmap levels: 256x256 (level 0), 128x128 (level 1), 64x64 (level 2), 32x32 (level 3), 16x16 (level 4), 8x8 (level 5), 4x4 (level 6), 2x2 (level 7), 1x1 (level 8).

See the documentation for [NearestMipmapNearest], [NearestMipmapLinear], [LinearMipmapNearest] and [LinearMipmapLinear] for details on how these filtering operations will make use of a mipmap.

Variants

Nearest

The sampled value is chosen to be the value of the texel whose coordinates are closest to the sampling coordinates.

Linear

The sampled value is calculated by linearly interpolating between the 4 texels that are closest to the sampling coordinates.

NearestMipmapNearest

First selects the mipmap level for which the texel size is closest to the fragment size, then the sampled value is chose to be the value of the texel whose coordinates are closest to the sampling coordinates.

NearestMipmapLinear

First selects the mipmap level for which the texel size is closest to the fragment size, then the sampled value is calculated by linearly interpolating between the 4 texels that are closest to the sampling coordinates.

LinearMipmapNearest

First selects both the nearest mipmap level for which the texel size is smaller than the fragment, as well as the nearest mipmap level for which the texel size is larger than the fragment; then samples a value from both mipmap levels by choosing the texel whose coordinates are closest to the sampling coordinates; finally, the sample value is calculated by linearly interpolating between these two values.

LinearMipmapLinear

First selects both the nearest mipmap level for which the texel size is smaller than the fragment, as well as the nearest mipmap level for which the texel size is larger than the fragment; then samples a value from both mipmap levels by linearly interpolating between the 4 texels that are closest to the sampling coordinates; finally, the sample value is calculated by linearly interpolating between these two values.

Trait Implementations

impl Clone for MinificationFilter[src]

impl PartialEq<MinificationFilter> for MinificationFilter[src]

impl Copy for MinificationFilter[src]

impl Debug for MinificationFilter[src]

Auto Trait Implementations

Blanket Implementations

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]