title | description | ms.assetid | keywords | topic_type | api_name | api_type | ms.topic | ms.date | api_location | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tex2D (HLSL reference) - Select the mip level |
Samples a 2D texture using a gradient to select the mip level. | tex2D (HLSL reference) |
0e8c32ed-d174-4045-9cbf-6c04586ea5bb |
|
|
|
|
reference |
05/31/2018 |
Samples a 2D texture using a gradient to select the mip level.
ret tex2D(s, t, ddx, ddy) |
---|
Item | Description |
---|---|
s |
[in] The sampler state. |
t |
[in] The texture coordinates. |
ddx |
[in] Rate of change of the surface geometry in the x direction. |
ddy |
[in] Rate of change of the surface geometry in the y direction. |
The value of the texture data.
Name | In/Out | Template Type | Component Type | Size |
---|---|---|---|---|
s | in | object | sampler2D | 1 |
t | in | vector | float | 2 |
ddx | in | vector | float | 2 |
ddy | in | vector | float | 2 |
ret | out | vector | float | 4 |
This function is supported in the following shader models.
Shader Model | Supported |
---|---|
Shader Model 4 | yes (pixel shader only) |
Shader Model 3 (DirectX HLSL) | yes (pixel shader only) |
Shader Model 2 (DirectX HLSL) | yes (pixel shader only) |
Shader Model 1 (DirectX HLSL) | no |
- Significant code reordering is done to move gradient computations outside of flow control.
- If the D3DPSHADERCAPS2_0 cap is set with D3DD3DPSHADERCAPS2_0_GRADIENTINSTRUCTIONS, the compiler maps this function to texldd.
When flow control is present in a shader, the result of a gradient calculation requested inside a given branch path is ambiguous when adjacent pixels may go down separate flow control paths. Therefore, it is deemed illegal to use any pixel shader operation that requests a gradient calculation to occur at a location that is inside a flow control construct which could vary across pixels for a given primitive being rasterized. If either side of an if statement with the branch attribute uses a gradient function a compiler error may be generated. See if Statement (DirectX HLSL).