texbem - ps

应用假凹凸环境映射转换。 这是通过使用地址扰动数据 (du、dv) 和 2D 凹凸环境矩阵修改目标寄存器的纹理地址数据来实现的。

语法

texbem dst, src

 

其中

  • 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 (阶段 m) u + D3DTSS_BUMPENVMAT00 (阶段 m) *t (n) R + D3DTSS_BUMPENVMAT10 (阶段 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 使用带颜色数据的纹理贴图。
  • 此指令在采样的纹理阶段上设置矩阵数据。
  • 这不同于固定函数管道的功能,其中扰动数据和矩阵占据同一纹理阶段。

像素着色器说明