_Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample
Description
Samples the texture at a given location using implicit level of detail.
Signature
/// Requires Capability Set 1: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( vector<float, isArray+Shape.dimensions> location) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 1; /// Requires Capability Set 2: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 1; /// Requires Capability Set 3: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset, float clamp) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 1; T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset, float clamp, out uint status) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 1; /// Requires Capability Set 1: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( SamplerState s, vector<float, isArray+Shape.dimensions> location) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 0; /// Requires Capability Set 2: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( SamplerState s, vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 0; /// Requires Capability Set 4: T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( SamplerState s, vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset, float clamp) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 0; T _Texture<T, Shape, isArray, isMS, sampleCount, access, isShadow, isCombined, format>.Sample( SamplerState s, vector<float, isArray+Shape.dimensions> location, vector<int, Shape.planeDimensions> offset, float clamp, out uint status) where T : ITexelElement where Shape : __ITextureShape where access == 0 where isCombined == 0;
Parameters
location : vector<float, isArray + Shape.dimensions>
The location to sample the texture at.
offset : vector<int, Shape.planeDimensions>
Texel offset to apply.
clamp : float
The maximum level of detail to use.
status : uint
[out] The result status of the operation. This parameter is currently only used when targeting HLSL. For other targets, the result status is always 0.
s : SamplerState
The SamplerState to use for the sampling operation. This parameter is omitted when this is a combined texture sampler type (isCombined==0).
Return value
The sampled texture value.
location is a vector of floats as follows:
- For 1d/2d/3d-textures, the vector is a 1d/2d/3d-vector specifying the sample location. Usually, normalized coordinates are used such that the coordinate range [0, 1] denotes the full span of the texture. Depending on the sampler state and the sampled texture type, other conventions may also be used. For example, GL_TEXTURE_RECTANGLE uses non-normalized texel locations.
- For cube textures, the location is a 3d-vector specifying the direction from the center of the cube at the sample. The direction does not need to be normalized.
- For texture arrays, the location vector is appended with the array index. The array index (float) is first rounded to the nearest integer value and then clamped to [0, d-1] where d is the number of array elements.
Remarks
The Sample function is defined for all read-only texture types, including Texture1D, Texture2D, Texture3D, TextureCube, Texture1DArray, Texture2DArray and TextureCubeArray.
This function requires the implicit sampling derivatives, which are always available in the fragment stage. In other stages, the derivatives are enabled on the target using the appropriate target extensions as necessary. It is an error to use this function when implicit derivatives cannot be enabled. See also capability GL_NV_compute_shader_derivatives.
This function is not available for read-write and write-only texture types.
For HLSL/D3D targets, the texture element type must be a scalar or vector of float or half types.
Availability and Requirements
Capability Set 1
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
cuda
Available in all stages.
metal
Available in all stages.
wgsl
Available in all stages.
spirv
Available in all stages.
Capability Set 2
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
metal
Available in all stages.
wgsl
Available in all stages.
spirv
Available in all stages.
Capability Set 3
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
metal
Available in all stages.
spirv
Available in all stages.
Requires capability: spvSparseResidency.
Capability Set 4
Defined for the following targets:
hlsl
Available in all stages.
glsl
Available in all stages.
cpp
Available in all stages.
metal
Available in all stages.
spirv
Available in all stages.
See Also
SampleBias, SampleLevel, SampleLevelZero, SampleGrad, SampleCmp, SampleCmpLevelZero, SampleCmpLevel, SampleCmpBias, SampleCmpGrad.