Microsoft DirectX 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3, 1.4) |
Multiplies the components of two source registers. The result is dest = src0 * src1.
mul dest, src0, src1
Argument | Description | Registers | Version | |||
---|---|---|---|---|---|---|
vn | cn | tn | rn | |||
dest | Destination register | x | 1.0 | |||
x | x | 1.1, 1.2, 1.3 | ||||
x | 1.4 | |||||
src0, src1 | Source register | x | x | x | x | 1.0, 1.1, 1.2, 1.3 |
x | x | 1.4 phase 1 | ||||
x | x | x | 1.4 phase 2 |
To learn more about registers, see Registers.
This example is for illustration only. The C code accompanying the shader has not been optimized for performance.
// This example combines the texture color and the diffuse color. // The shader is shown below. ps.1.0 // Version instruction tex t0 // Declare texture. mul r0, v0, t0 // Multiply diffuse color with gradient texture. // The following images show the contents of the source registers the // resulting output register. // Where src1 is white, the destination pixel color is the same as the // source pixel color since dest = src * 1.0. // Where src1 is black, the destination is also black. // The pixel colors in the middle of the destination image are a blend // of src0 and src1.
// Additional code loads a texture in texture stage 0. LPDIRECT3DDEVICE8 m_pd3dDevice; // Init this device pointer in the application. LPDIRECT3DTEXTURE8 m_pTexture0; // Use this variable to hold a pointer to the texture. TCHAR strPath[512] = "textureFile.jpg"; D3DUtil_CreateTexture( m_pd3dDevice, strPath, &m_pTexture0, D3DFMT_R5G6B5 ); m_pd3dDevice->SetTexture( 0, m_pTexture0 );