tex2Dlod (Windows)

Switch View :
ScriptFree
tex2Dlod

Applies to: desktop apps only

Samples a 2D texture with mipmaps. The mipmap LOD is specified in t.w.

ret tex2Dlod(s, t)

 

Parameters

ItemDescription

s

[in] The sampler state.

t

[in] The texture coordinate.

 

Return Value

The value of the texture data.

Type Description

NameIn/Out Template Type Component Type Size
sinobject sampler2D 1
tinvector float 4
retoutvector float 4

 

Minimum Shader Model

This function is supported in the following shader models.

Shader ModelSupported
Shader Model 3 (DirectX HLSL) and higher shader modelsyes
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

 

Remarks

Starting with Direct3D 10, you can use new HLSL syntax to access textures and other resources. You can replace intrinsic-style texture lookup functions, such as tex2Dlod, with a more object-oriented style. In this object-oriented style, textures are decoupled from samplers and have methods for loading and sampling.

To sample a 2D texture, instead of using tex2Dlod as in this code:



sampler S;
...
color = tex2Dlod(S, Location);


Use the SampleLevel method of a Texture Object as in this code:



Texture2D MyTexture;
SamplerState MySampler;
...
color = MyTexture.SampleLevel(MySampler, Location, LOD);


To use the intrinsic-style texture lookup functions, such as tex2Dlod, with shader model 4 and higher, use D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY to compile. However, if you want to target shader model 4 and higher (even *_4_0_level_9_*) with newer object-oriented style code, migrate to the newer HLSL syntax.

See also

Intrinsic Functions (DirectX HLSL)

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Content

billybaloop
The 4D texcoord is required to choose a mip level
From http://www.gamedev.net/topic/600108-tex2dlod-usage/,

"... [the 4d texcoord] lets you explicitly specify the mip level that you want to sample. So X and Y are the UV coordinates as usual, Z is ignored, and W is the mip level. If you have linear mip filtering on and you specify a non-integral value for W, then you'll get a blend of the two closest mip levels."