GPUSampler
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{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}}
Instance properties
- {{domxref("GPUSampler.label", "label")}}
- : A string providing a label that can be used to identify the object, for example in {{domxref("GPUError")}} messages or console warnings.
Examples
The following snippet creates a GPUSampler that does trilinear filtering and repeats texture coordinates:
js
// …
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
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- The WebGPU API