files/en-us/web/api/gpusampler/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The GPUSampler interface of the {{domxref("WebGPU API", "WebGPU API", "", "nocode")}} represents an object that can control how shaders transform and filter texture resource data.
A GPUSampler object instance is created using the {{domxref("GPUDevice.createSampler()")}} method.
{{InheritanceDiagram}}
The following snippet creates a GPUSampler that does trilinear filtering and repeats texture coordinates:
// …
const sampler = device.createSampler({
addressModeU: "repeat",
addressModeV: "repeat",
magFilter: "linear",
minFilter: "linear",
mipmapFilter: "linear",
});
The WebGPU samples Shadow Mapping sample uses comparison samplers to sample from a depth texture to render shadows.
{{Specifications}}
{{Compat}}