Gather (DirectX HLSL Texture Object)
Gets the four samples (red component only) that would be used for bilinear interpolation when sampling a texture.
<Template Type>4 Object.Gather( sampler_state S, float2|3|4 Location [, int2 Offset] );
Parameters
| Item | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Object |
The following texture-object types are supported: Texture2D, Texture2DArray, TextureCube, TextureCubeArray. |
||||||||
| S |
[in] A Sampler state. This is an object declared in an effect file that contains state assignments. |
||||||||
| Location |
[in] The texture coordinates. The argument type is dependent on the texture-object type.
|
||||||||
Offset |
[in] An optional texture coordinate offset, which can be used for any texture-object type; the offset is applied to the location before sampling. The argument type is dependent on the texture-object type. For shaders targeting Shader Model 5.0 and above, the 6 least significant bits of each offset value is honored as a signed value, yielding [-32..31] range. For previous shader model shaders, offsets need to be immediate integers between -8 and 7.
|
Return Value
A four-component vector, with four components of red data, whose type is the same as the texture's template type.
Minimum Shader Model
This function is supported in the following shader models.
| vs_4_0 | vs_4_1 | ps_4_0 | ps_4_1 | gs_4_0 | gs_4_1 |
|---|---|---|---|---|---|
| x | x | x |
- TextureCubeArray is available in Shader Model 4.1 or higher.
- Shader Model 4.1 is available in Direct3D 10.1 or higher.
Example
Texture2D<int1> Tex2d;
Texture2DArray<int2> Tex2dArray;
TextureCube<int3> TexCube;
TextureCubeArray<float2> TexCubeArray;
SamplerState s;
int4 main (float4 f : SV_Position) : SV_Target
{
int2 iOffset = int2(2,3);
int4 i1 = Tex2d.Gather(s, f.xy);
int4 i2 = Tex2d.Gather(s, f.xy, iOffset);
int4 i3 = Tex2dArray.Gather(s, f.xyz);
int4 i4 = Tex2dArray.Gather(s, f.xyz, iOffset);
int4 i5 = TexCube.Gather(s, f.xyzw);
float4 f6 = TexCubeArray.Gather(s, f.xyzw);
return i1+i2+i3+i4+i5+int4(f6);
}
Related topics
Feedback
Submit and view feedback for