[][src]Module vulkano::sampler

How to retrieve data from an image within a shader.

When you retrieve data from an image, you have to pass the coordinates of the pixel you want to retrieve. The implementation then performs various calculations, and these operations are what the Sampler struct describes.

Sampling is a very complex topic but that hasn't changed much since the beginnings of 3D rendering. Documentation here is missing, but any tutorial about OpenGL or DirectX can teach you how it works.

Examples

A simple sampler for most usages:

use vulkano::sampler::Sampler;

let _sampler = Sampler::simple_repeat_linear_no_mipmap(device.clone());

More detailed sampler creation:

use vulkano::sampler;

let _sampler = sampler::Sampler::new(device.clone(), sampler::Filter::Linear,
                                     sampler::Filter::Linear,
                                     sampler::MipmapMode::Nearest,
                                     sampler::SamplerAddressMode::Repeat,
                                     sampler::SamplerAddressMode::Repeat,
                                     sampler::SamplerAddressMode::Repeat, 1.0, 1.0,
                                     0.0, 100.0).unwrap();;

About border colors

One of the possible values of SamplerAddressMode and UnnormalizedSamplerAddressMode is ClampToBorder. This value indicates that accessing an image outside of its range must return the specified color.

However this comes with restrictions. When using a floating-point border color, the sampler can only be used with floating-point or depth image views. When using an integer border color, the sampler can only be used with integer or stencil image views. In addition to this, you can't use an opaque black border color with an image view that uses components swizzling.

Note: The reason for this restriction about opaque black borders is that the value of the alpha is 1.0 while the value of the color components is 0.0. In the other border colors, the value of all the components is the same.

Samplers that don't use ClampToBorder are not concerned by these restrictions.

Re-exports

pub use pipeline::depth_stencil::Compare;

Structs

Sampler

Describes how to retrieve data from an image within a shader.

Enums

BorderColor

The color to use for the border of an image.

Filter

Describes how the color of each pixel should be determined.

MipmapMode

Describes which mipmap from the source to use.

SamplerAddressMode

How the sampler should behave when it needs to access a pixel that is out of range of the texture.

SamplerCreationError

Error that can happen when creating an instance.

UnnormalizedSamplerAddressMode

How the sampler should behave when it needs to access a pixel that is out of range of the texture.