Gather (DirectX HLSL Texture Object)

Gets the four samples (red component only) that would be used for bilinear interpolation when sampling a texture.


Item Description
The following [texture-object]( types are supported: Texture2D, Texture2DArray, TextureCube, TextureCubeArray.
[in] A [Sampler state]( This is an object declared in an effect file that contains state assignments.
[in] The texture coordinates. The argument type is dependent on the texture-object type.
Texture-Object Type Parameter Type
Texture2D float2
Texture2DArray, TextureCube float3
TextureCubeArray float4


[in] An optional texture coordinate offset, which can be used for any texture-object types. The offset is applied to the location before sampling. The argument type is dependent on the texture-object type. For more info, see [Applying Integer Offsets](

Texture-Object Type Parameter Type
Texture2D, Texture2DArray int2
TextureCube, TextureCubeArray not supported

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
  1. TextureCubeArray is available in Shader Model 4.1 or higher.
  2. Shader Model 4.1 is available in Direct3D 10.1 or higher.


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,;
    int4 i4 = Tex2dArray.Gather(s,, iOffset);

    int4 i5 = TexCube.Gather(s, f.xyzw);

    float4 f6 = TexCubeArray.Gather(s, f.xyzw);

    return i1+i2+i3+i4+i5+int4(i6);