SetSamplerState()

设置纹理采样属性  
HRESULT  SetSamplerState(  
  
                   DWORD    Sampler,     //指定纹理采样属性的纹理层ID(0~7)  
     D3DSAMPLERSTATETYPE    Type,       //纹理过滤类型  
                   DWORD    Value     //设置纹理采样属性值  
);  

第二个参数D3DSAMPLERSTATETYPE  Type 取值: 
D3DSAMP_MAGFILTER                   //处理放大过滤 
D3DSAMP_MINFILTER                //处理缩小过滤 
D3DSAMP_MIPFILTER                //多纹理过滤 
D3DSAMP_MIPMAPLODBIAS            //多级纹理级数偏移值,初始值为0 
D3DSAMP_MAXMIPLEVEL                        //最大多纹理级别,初始值为0 
D3DSAMP_MAXANISOTROPY            //各向异性,初始为1 
 
 
第三个参数Value取值: 
D3DTEXF_NONE                       //不使用特殊的采样方式 
D3DTEXF_POINT                     //最近点采样 
D3DTEXF_LINEAR                    //线性纹理采样 
D3DTEXF_ANISOTROPIC               //各向异性纹理采样 
 
typedef enum _D3DSAMPLERSTATETYPE {
    D3DSAMP_ADDRESSU = 1,
    D3DSAMP_ADDRESSV = 2,
    D3DSAMP_ADDRESSW = 3,
    D3DSAMP_BORDERCOLOR = 4,
    D3DSAMP_MAGFILTER = 5,
    D3DSAMP_MINFILTER = 6,
    D3DSAMP_MIPFILTER = 7,
    D3DSAMP_MIPMAPLODBIAS = 8,
    D3DSAMP_MAXMIPLEVEL = 9,
    D3DSAMP_MAXANISOTROPY = 10,
    D3DSAMP_SRGBTEXTURE = 11,
    D3DSAMP_ELEMENTINDEX = 12,
    D3DSAMP_DMAPOFFSET = 13,
    D3DSAMP_FORCE_DWORD = 0x7fffffff
} D3DSAMPLERSTATETYPE;

Constants

D3DSAMP_ADDRESSU

Texture-address mode for the u coordinate. The default is D3DTADDRESS_WRAP. For more information, see D3DTEXTUREADDRESS.

D3DSAMP_ADDRESSV

Texture-address mode for the v coordinate. The default is D3DTADDRESS_WRAP. For more information, see D3DTEXTUREADDRESS.

D3DSAMP_ADDRESSW

Texture-address mode for the w coordinate. The default is D3DTADDRESS_WRAP. For more information, see D3DTEXTUREADDRESS.

D3DSAMP_BORDERCOLOR

Border color or type D3DCOLOR. The default color is 0x00000000.

D3DSAMP_MAGFILTER

Magnification filter of type D3DTEXTUREFILTERTYPE. The default value is D3DTEXF_POINT.

D3DSAMP_MINFILTER

Minification filter of type D3DTEXTUREFILTERTYPE. The default value is D3DTEXF_POINT.

D3DSAMP_MIPFILTER

Mipmap filter to use during minification. See D3DTEXTUREFILTERTYPE. The default value is D3DTEXF_NONE.

D3DSAMP_MIPMAPLODBIAS

Mipmap level of detail (LOD) bias. The default value is zero.

D3DSAMP_MAXMIPLEVEL

LOD index of largest map to use. Values range from 0 to (n - 1) where 0 is the largest. The default value is zero.

D3DSAMP_MAXANISOTROPY

DWORD maximum anisotropy. The default value is 1.

D3DSAMP_SRGBTEXTURE

Gamma correction value. The default value is 0, which means gamma is 1.0 and no correction is required. Otherwise, this value means that the sampler should assume gamma of 2.2 on the content and convert it to linear (gamma 1.0) before presenting it to the pixel shader.

D3DSAMP_ELEMENTINDEX

When a multielement texture is assigned to the sampler, this indicates which element index to use. The default value is 0.

D3DSAMP_DMAPOFFSET

Vertex offset in the presampled displacement map. This is a constant used by the tessellator, its default value is 0.

D3DSAMP_FORCE_DWORD

This value forces a 32-bit enumeration.

 
 
 
其他用法:
包装纹理寻址  
 SetSamplerState(0 , D3DSAMP_ADDRESSU , D3DTADDRESS_WRAP);  
SetSamplerState(0 , D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);  
=================================================================  
==============  
                                   DirectX  
=================================================================  
==============  
  
镜像纹理寻址  
 SetSamplerState(0 , D3DSAMP_ADDRESSU , D3DTADDRESS_MIRROR);  
SetSamplerState(0 , D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);  
=================================================================  
==============  
                                     
=================================================================  
==============  
  
夹取纹理寻址  
SetSamplerState(0 , D3DSAMP_ADDRESSU , D3DTADDRESS_CLAMP);  
  
                               
SetSamplerState(0 , D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);  
=================================================================  
==============  
                                    
=================================================================  
==============  
  
边框颜色纹理寻址  
SetSamplerState(0 , D3DSAMP_BORDERCOLOR , 0xffff0000); //设置边框颜色  
 SetSamplerState(0 , D3DSAMP_ADDRESSU , D3DTADDRESS_BORDER);  
SetSamplerState(0 , D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER;  
=================================================================  
==============  
                                    
=================================================================  
==============  
  
一次镜像纹理寻址  
 SetSamplerState(0 , D3DSAMP_ADDRESSU , D3DTADDRESS_MIRRORONCE);  
SetSamplerState(0 , D3DSAMP_ADDRESSV, D3DTADDRESS_MIRRORONCE);  
=================================================================  
==============  
                                   DirectX  
=================================================================  
==============  
  
纹理包装  
SetRenderState(D3DRS_WRAP0 , D3DWRAP_U|D3DWRAP_V); //设置在u和v方向上同时使用纹理包装 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值