青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

紋理映射基礎(3)

當Direct3D渲染一個圖元時,必須將它通過坐標變換映射到二維屏幕上。如果圖元有紋理,Direct3D就需要用紋理來產生圖元的二維渲染圖像上每個像素的顏色。對于圖元在二維屏幕上圖像的每個像素來說,都必須從紋理中獲得一個顏色,從紋理中為每個像素獲取顏色的過程稱為紋理過濾(texture filtering)。

大多數情況下,屏幕顯示的圖形大小與紋理貼圖大小不相同,換句話說,這個紋理將被映射到一個比它大或小的圖元的圖像上,這樣紋理常常會被放大或縮小。對紋理的放大會造成許多像素被映射到同一個紋理元素,圖形渲染結果會有色塊的感覺。縮小一個紋理意味著一個像素被映射到許多紋理元素,圖形看上去會閃爍失真或有鋸齒。為了解決這些問題,可以將相關紋理元素的顏色融合到一個像素上,如何將多個紋理元素的顏色融合到一個像素上取決于紋理過濾方式。

Direct3D支持4種紋理過濾方式,分別是:最近點采樣(nearest-point sampling)、線性紋理過濾(linear texture filtering)、各向異性紋理過濾(anisotropic texture filtering)和多級漸進紋理過濾(texture filtering with mipmaps)。不同的紋理過濾方式產生的圖像效果差別可能很大。

4種紋理過濾方法各有優缺點。例如,線性過濾生成的圖像較粗糙,但計算量小。多級漸進紋理過濾的效果通常最好,特別是和各項異性過濾聯合使用時效果更好,但是它需要Direct3D提供的內存空間最多,計算量也最大。

紋理采樣屬性設置函數IDirect3DDevice9::SetSamplerState()可以用來設置紋理過濾方式。該函數的聲明如下:

Sets the sampler state value.

HRESULT SetSamplerState(
DWORD Sampler,
D3DSAMPLERSTATETYPE Type,
DWORD Value
);

Parameters

Sampler
[in] The sampler stage index.
Type
[in] This parameter can be any member of the D3DSAMPLERSTATETYPE enumerated type.
Value
[in] State value to set. The meaning of this value is determined by the Type parameter.

Return Values

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be D3DERR_INVALIDCALL.

參數Type屬于D3DSAMPLERSTATETYPE類型,用來指定對哪種紋理采樣屬性賦值。

D3DSAMPLERSTATETYPE

Sampler states define texture sampling operations such as texture addressing and texture filtering. Some sampler states set-up vertex processing, and some set-up pixel processing. Sampler states can be saved and restored using stateblocks (see State Blocks Save and Restore State (Direct3D 9)).

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, *LPD3DSAMPLERSTATETYPE;

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 bias. The default value is zero.
D3DSAMP_MAXMIPLEVEL
level-of-detail 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
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.

其中,D3DSAMP_MAGFILTER、D3DSAMP_MINFILTER、D3DSAMP_MIPFILTER、D3DSAMP_MIPMAPLODBIAS、D3DSAMP_MAXMIPLEVEL和D3DSAMP_MAXANISOTROPY用來控制紋理過濾方式。

D3DTEXTUREFILTERTYPE

Defines texture filtering modes for a texture stage.

typedef enum D3DTEXTUREFILTERTYPE
{
D3DTEXF_NONE = 0,
D3DTEXF_POINT = 1,
D3DTEXF_LINEAR = 2,
D3DTEXF_ANISOTROPIC = 3,
D3DTEXF_PYRAMIDALQUAD = 6,
D3DTEXF_GAUSSIANQUAD = 7,
D3DTEXF_CONVOLUTIONMONO = 8,
D3DTEXF_FORCE_DWORD = 0x7fffffff,
} D3DTEXTUREFILTERTYPE, *LPD3DTEXTUREFILTERTYPE;

Constants

D3DTEXF_NONE
Mipmapping disabled. The rasterizer should use the magnification filter instead.
D3DTEXF_POINT
Point filtering used as a texture magnification or minification filter. The texel with coordinates nearest to the desired pixel value is used. The texture filter to be used between mipmap levels is nearest-point mipmap filtering. The rasterizer uses the color from the texel of the nearest mipmap texture.
D3DTEXF_LINEAR
Bilinear interpolation filtering used as a texture magnification or minification filter. A weighted average of a 2 x 2 area of texels surrounding the desired pixel is used. The texture filter to use between mipmap levels is trilinear mipmap interpolation. The rasterizer linearly interpolates pixel color, using the texels of the two nearest mipmap textures.
D3DTEXF_ANISOTROPIC
Anisotropic texture filtering used as a texture magnification or minification filter. Compensates for distortion caused by the difference in angle between the texture polygon and the plane of the screen.
D3DTEXF_PYRAMIDALQUAD
A 4-sample tent filter used as a texture magnification or minification filter.
D3DTEXF_GAUSSIANQUAD
A 4-sample Gaussian filter used as a texture magnification or minification filter.
D3DTEXF_CONVOLUTIONMONO
Convolution filter for monochrome textures. See D3DFMT_A1.
Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.

D3DTEXF_FORCE_DWORD
Forces this enumeration to compile to 32 bits in size. Without this value, some compilers would allow this enumeration to compile to a size other than 32 bits. This value is not used.

Remarks

To check if a format supports texture filter types other than D3DTEXF_POINT (which is always supported), call IDirect3D9::CheckDeviceFormat with D3DUSAGE_QUERY_FILTER.

Set a texture stage's magnification filter by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MAGFILTER value as the second parameter and one member of this enumeration as the third parameter.

Set a texture stage's minification filter by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MINFILTER value as the second parameter and one member of this enumeration as the third parameter.

Set the texture filter to use between-mipmap levels by calling IDirect3DDevice9::SetSamplerState with the D3DSAMP_MIPFILTER value as the second parameter and one member of this enumeration as the third parameter.

Not all valid filtering modes for a device will apply to volume maps. In general, D3DTEXF_POINT and D3DTEXF_LINEAR magnification filters will be supported for volume maps. If D3DPTEXTURECAPS_MIPVOLUMEMAP is set, then the D3DTEXF_POINT mipmap filter and D3DTEXF_POINT and D3DTEXF_LINEAR minification filters will be supported for volume maps. The device may or may not support the D3DTEXF_LINEAR mipmap filter for volume maps. Devices that support anisotropic filtering for 2D maps do not necessarily support anisotropic filtering for volume maps. However, applications that enable anisotropic filtering will receive the best available filtering (probably linear) if anisotropic filtering is not supported.

Unsigned Formats

Data in an unsigned format must be positive. Unsigned formats use combinations of (R)ed, (G)reen, (B)lue, (A)lpha, (L)uminance, and (P)alette data. Palette data is also referred to as color indexed data because the data is used to index a color palette.

Unsigned format flags Value Format
D3DFMT_R8G8B8 20 24-bit RGB pixel format with 8 bits per channel.
D3DFMT_A8R8G8B8 21 32-bit ARGB pixel format with alpha, using 8 bits per channel.
D3DFMT_X8R8G8B8 22 32-bit RGB pixel format, where 8 bits are reserved for each color.
D3DFMT_R5G6B5 23 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
D3DFMT_X1R5G5B5 24 16-bit pixel format where 5 bits are reserved for each color.
D3DFMT_A1R5G5B5 25 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
D3DFMT_A4R4G4B4 26 16-bit ARGB pixel format with 4 bits for each channel.
D3DFMT_R3G3B2 27 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
D3DFMT_A8 28 8-bit alpha only.
D3DFMT_A8R3G3B2 29 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
D3DFMT_X4R4G4B4 30 16-bit RGB pixel format using 4 bits for each color.
D3DFMT_A2B10G10R10 31 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
D3DFMT_A8B8G8R8 32 32-bit ARGB pixel format with alpha, using 8 bits per channel.
D3DFMT_X8B8G8R8 33 32-bit RGB pixel format, where 8 bits are reserved for each color.
D3DFMT_G16R16 34 32-bit pixel format using 16 bits each for green and red.
D3DFMT_A2R10G10B10 35 32-bit pixel format using 10 bits each for red, green, and blue, and 2 bits for alpha.
D3DFMT_A16B16G16R16 36 64-bit pixel format using 16 bits for each component.
D3DFMT_A8P8 40 8-bit color indexed with 8 bits of alpha.
D3DFMT_P8 41 8-bit color indexed.
D3DFMT_L8 50 8-bit luminance only.
D3DFMT_L16 81 16-bit luminance only.
D3DFMT_A8L8 51 16-bit using 8 bits each for alpha and luminance.
D3DFMT_A4L4 52 8-bit using 4 bits each for alpha and luminance.
D3DFMT_A1 118 1-bit monochrome.
Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.

D3DFMT_BINARYBUFFER 199 Binary format indicating that the data has no inherent type.
Differences between Direct3D 9 and Direct3D 9Ex:

This flag is available in Direct3D 9Ex only.


posted on 2008-05-07 08:16 lovedday 閱讀(2930) 評論(1)  編輯 收藏 引用

評論

# re: 紋理映射基礎(3) 2008-12-03 16:57

垃圾  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久麻豆一区二区| 日韩视频久久| 亚洲精品色图| 国产日韩在线视频| 亚洲视频视频在线| 亚洲一区二区在线免费观看视频| 久久精品国产亚洲一区二区三区| 欧美成人国产一区二区| 国产农村妇女精品| 国产欧美一区二区精品婷婷 | 六月丁香综合| 免费短视频成人日韩| 亚洲永久免费| 欧美在线视频一区二区| 久久香蕉国产线看观看av| 欧美成人黄色小视频| 欧美综合二区| 亚洲韩国青草视频| 国产精品嫩草影院av蜜臀| 亚洲视频图片小说| 久久久久久精| 在线不卡免费欧美| 欧美精品在线播放| 国产视频一区二区在线观看| 亚洲免费播放| 亚洲在线免费视频| 亚洲福利视频二区| 欧美国产视频在线| 久久国产主播| 亚洲一区3d动漫同人无遮挡| 国产亚洲一区二区精品| 久久精品国产精品| 亚洲欧洲在线免费| 亚洲黑丝在线| 欧美小视频在线| 欧美在线视频一区二区| 亚洲综合999| 欧美成人高清视频| 亚洲欧美日韩爽爽影院| 免播放器亚洲一区| 久久久久久久999精品视频| 国产日韩欧美精品在线| 欧美网站在线观看| 亚洲激情亚洲| 日韩一区二区免费看| 欧美影院成年免费版| 一区国产精品| 亚洲国产精品t66y| 永久555www成人免费| 亚洲综合日本| 久久精品国产精品亚洲综合| 欧美成人在线网站| 欧美xx视频| 午夜免费日韩视频| 欧美日产国产成人免费图片| 亚洲国产成人91精品| 欧美激情一二三区| 一区二区欧美在线观看| 亚洲精品免费一二三区| 国产综合第一页| 亚洲综合首页| 蜜臀av一级做a爰片久久| 久久一二三国产| 久久se精品一区精品二区| 欧美视频在线一区| 国产精品久久二区二区| 亚洲国产成人精品女人久久久 | 亚洲宅男天堂在线观看无病毒| 免费不卡欧美自拍视频| 裸体一区二区三区| 欧美日韩在线播放三区四区| 欧美视频在线一区| 韩国免费一区| 亚洲一区三区电影在线观看| 欧美一区视频在线| 欧美一级欧美一级在线播放| 免费人成精品欧美精品| 亚洲人成人一区二区三区| 欧美激情亚洲| 欧美一区二区在线免费播放| 国产精品婷婷| 亚洲国产精品久久久久秋霞蜜臀| 亚洲老板91色精品久久| 亚洲一区中文| 亚洲老板91色精品久久| 小处雏高清一区二区三区| 亚洲欧美日韩成人| 一本色道久久综合亚洲精品高清| 久久亚洲综合色| 在线观看国产日韩| 另类av导航| 亚洲精品视频在线播放| 国产精品美女xx| 亚洲香蕉在线观看| 久久―日本道色综合久久| 国产精品免费网站在线观看| 国产日韩欧美视频| 久久婷婷麻豆| 欧美日韩亚洲另类| 久久久久久夜精品精品免费| 久久婷婷影院| 国产视频观看一区| 欧美顶级少妇做爰| 国产伦精品一区二区三区四区免费 | 欧美日韩国产成人在线免费| 国产精品视频自拍| 午夜久久福利| 欧美超级免费视 在线| 亚洲天堂网在线观看| 欧美成人精品激情在线观看| 日韩午夜在线观看视频| 一区二区三区免费在线观看| 国产欧美精品在线观看| 亚洲电影第1页| 136国产福利精品导航| 蜜臀久久99精品久久久画质超高清| 欧美日韩综合网| 午夜精品999| 欧美三日本三级少妇三2023 | 亚洲欧洲日韩综合二区| 久久久久久久性| 亚洲女人天堂成人av在线| 国产伦精品一区二区三| 99re热这里只有精品免费视频| 玖玖国产精品视频| 一区视频在线| 毛片av中文字幕一区二区| 免费观看成人鲁鲁鲁鲁鲁视频 | 亚洲日韩中文字幕在线播放| 国产精品乱码| 欧美精品综合| 欧美在线观看视频| 99www免费人成精品| 欧美大片免费看| 久久精品国产综合| 亚洲欧美999| 亚洲午夜视频| 99re66热这里只有精品4| 国产欧美在线看| 米奇777超碰欧美日韩亚洲| 亚洲男人av电影| 99精品久久免费看蜜臀剧情介绍| 久久xxxx精品视频| 亚洲欧美精品中文字幕在线| 国模私拍视频一区| 国产视频一区免费看| 国产精品久久77777| 国产酒店精品激情| 国产欧美日韩专区发布| 国产精品一区二区在线| 欧美一区二区视频97| 亚洲欧美制服中文字幕| 午夜精品一区二区三区在线| 亚洲在线黄色| 久久一区二区三区四区五区| 一区二区日韩| 欧美一级久久久| 久久久久久久综合色一本| 午夜电影亚洲| 欧美影视一区| 亚洲日本乱码在线观看| 亚洲日本理论电影| 午夜精品免费视频| 久久激情五月婷婷| 久久影院亚洲| 亚洲国产成人av在线| 久久精品久久99精品久久| 在线一区二区三区四区五区| 男人插女人欧美| 欧美主播一区二区三区| 欧美日韩三级电影在线| 国产精品尤物福利片在线观看| 国产日韩欧美一区二区| 亚洲国产婷婷香蕉久久久久久99 | 一本色道久久88综合亚洲精品ⅰ| 日韩一区二区精品视频| 亚洲看片网站| 欧美日韩国产欧| 欧美成ee人免费视频| 亚洲毛片在线| 亚洲国产精品999| 欧美激情综合五月色丁香小说 | 欧美激情1区| 国产亚洲欧美日韩精品| 欧美在线影院| 久久99伊人| 能在线观看的日韩av| 99精品视频免费观看| 亚洲成人在线免费| 亚洲精品日韩久久| 国产日韩亚洲欧美| 欧美一区二区三区喷汁尤物| 一区二区三区日韩在线观看 | 欧美刺激性大交免费视频| 国产真实久久| 久久av在线看| 久久亚洲春色中文字幕| 一本色道久久综合亚洲精品高清| 99热免费精品| 亚洲精品乱码久久久久久日本蜜臀|