In my DirectX9 sample when I do the below things all works fine and I get the desired rotating triangle on screen,
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
But when I try to do the same using shaders nothing gets rendered
D3DXMATRIXA16 matWorldViewProj = matWorld * matView * matProj;
constantTable->SetMatrix(g_pd3dDevice, "g_mWorldViewProjection", &matWorldViewProj);
//Vertex Shader snippet
Output.Position = mul(In.Position,g_mWorldViewProjection);
when I made below change in the vertex shader
Output.Position = In.Position;
I get the static triangle rendered on the screen.
What could be the probable error in my code/technique ?
( profile: vs_3_0 using D3DXCompileShaderFromFile )
At the compilation of the pixelshader you overwrite your variable constantTable
. So the matrix is only set in the pixelshader and not in the vertexshader. Either you declare an additional variable constantTablePix
or set the parameter to NULL
if you dont need to pass information to the pixelshader.
The correct order for the matrix is. (I never get the order right, but it works now :) )
D3DXMATRIXA16 matWorldViewProj = matWorld * matView * matProj;