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 |
|---|---|
|
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 TypeParameter Type Texture2Dfloat2 Texture2DArray, TextureCubefloat3 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 TypeParameter Type Texture2D, Texture2DArrayint2 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 |
- 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(i6);
}
Related topics