Share via


texbem - ps

套用假的碰撞環境對應轉換。 這可藉由修改目的地暫存器紋理位址資料、使用位址調整資料 (du、dv) ,以及 2D 凸凸環境矩陣來完成。

Syntax

texbem dst, src

 

where

  • dst 是目的地暫存器。
  • src 是來源暫存器。

備註

圖元著色器版本 1_1 1_2 1_3 1_4 2_0 2_x 2_sw 3_0 3_sw
texbem x x x

 

src 暫存器中的紅色和綠色色彩資料會解譯為 du,dv) 的反轉資料 (。

此指令會使用 2D 凸凸環境對應矩陣,轉換來源暫存器中的紅色和綠色元件。 結果會新增至對應至目的地暫存器編號的紋理座標集,並用來取樣目前的紋理階段。

這項作業一律會將 du 和 dv 解譯為已簽署的數量。 對於 1_0 和 1_1 版,輸入引數不允許 來源暫存器帶正 負號調整輸入修飾詞 (_bx2) 。

當輸入紋理包含帶正負號格式資料時,這個指令會產生已定義的結果。 只有在前兩個通道包含帶正負號的資料時,混合格式資料才能運作。 如需介面格式的詳細資訊,請參閱 D3DFORMAT

這可用於根據地址變化的各種技術,包括假的個別圖元環境對應和擴散光源 () 。

使用此指令時,紋理暫存器必須遵循下列順序。

// The texture assigned to stage t(n) contains the (du,dv) data
// The texture assigned to stage t(m) is sampled
tex     t(n)                    
texbem  t(m),  t(n)      where m > n

指示內完成的計算如下所示。

// 1. New values for texture addresses (u',v') are calculated
// 2. Sample the texture using (u',v')

u' = TextureCoordinates (stage m) u + D3DTSS_BUMPENVMAT00 (stage m) *t (n) R + D3DTSS_BUMPENVMAT10 (stage m) *t (n) G v' = TextureCoordinates (stage m) v + D3DTSS_BUMPENVMAT01 (stage m) *t (n) R + D3DTSS_BUMPENVMAT11 (stage m) *t (n) G t (m) RGBA = TextureSample (stage m)

使用 (u',v') 作為座標

註冊 texbem - ps 或 texbeml - ps 指令讀取的資料,稍後無法讀取,但其他 texbem - ps 或 texbeml - ps 除外。

// This example demonstrates the validation error caused by t0 being reread:
ps_1_1
tex t0
texbem t1, t0
add r0, t1, t0

(Instruction Error) (Statement 4) Register data that has been read by 
texbem or texbeml instruction cannot be read by other instructions

範例

以下是已識別紋理地圖和已識別紋理階段的範例著色器。

ps_1_1
tex t0              ; Define t0 to get a 2-tuple DuDv
texbem t1, t0       ; Compute (u',v')
                    ; Sample t1 using (u',v')
mov r0, t1          ; Output result

texbem 需要下列紋理階段中的下列紋理。

  • 階段 0 會指派具有 (du、dv) 翻轉資料的凸凸地圖。
  • 階段 1 使用紋理貼圖搭配色彩資料。
  • 此指令會設定取樣之紋理階段的矩陣資料。
  • 這與固定函式管線的功能不同,其中探查資料和矩陣佔用相同的紋理階段。

圖元著色器指示