Gather (DirectX HLSL Texture Object)

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

ItemDescription

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.

Texture-Object TypeParameter Type
Texture2Dfloat2
Texture2DArray, TextureCubefloat3
TextureCubeArray¹float4

 

Offset

[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_0vs_4_1²ps_4_0ps_4_1²gs_4_0gs_4_1²
xxx

 

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

Texture-Object

 

 

Show:
© 2016 Microsoft