?/TD> |
Microsoft DirectX 9.0 |
Vertex shader input register for a 4-D floating-point constant.
They can be set using def or IDirect3DDevice9::SetVertexShaderConstantF.
Here is an example declaring two floating-point constants within a shader.
def c40, 0.0f,0.0f,0.0f,0.0f;
These constants are loaded every time IDirect3DDevice9::SetVertexShader is called.
Here is an example using the application programming interface (API).
// Set up the vertex shader constants. { D3DXMATRIXA16 mat; D3DXMatrixMultiply( &mat, &m_matView, &m_matProj ); D3DXMatrixTranspose( &mat, &mat ); D3DXVECTOR4 vA( sinf(m_fTime)*15.0f, 0.0f, 0.5f, 1.0f ); D3DXVECTOR4 vD( D3DX_PI, 1.0f/(2.0f*D3DX_PI), 2.0f*D3DX_PI, 0.05f ); // Taylor series coefficients for sin and cos. D3DXVECTOR4 vSin( 1.0f, -1.0f/6.0f, 1.0f/120.0f, -1.0f/5040.0f ); D3DXVECTOR4 vCos( 1.0f, -1.0f/2.0f, 1.0f/ 24.0f, -1.0f/ 720.0f ); m_pd3dDevice->SetVertexShaderConstantF( 0, (float*)&mat, 4 ); m_pd3dDevice->SetVertexShaderConstantF( 4, (float*)&vA, 1 ); m_pd3dDevice->SetVertexShaderConstantF( 7, (float*)&vD, 1 ); m_pd3dDevice->SetVertexShaderConstantF( 10, (float*)&vSin, 1 ); m_pd3dDevice->SetVertexShaderConstantF( 11, (float*)&vCos, 1 ); }
If you are setting constant values with the API, there is no shader declaration required. For a more complete code sample, see the VertexShader software development kit (SDK) sample.