Hi,
recently i discovered that was loading an effect-file with a vertexshader but not even used it. I still set the matrices with device->SetTransform(D3DTS_WORLD/VIEW/PROJ.,&matrix);
so i just changed that to effect->SetMatrix("matWorld"/../..,&matrix) but now my vertices are not transformed at all :( .
Here's what my fx file looks like:
string Position_Pass_0_Model : ModelData = "C:/Program Files/ATI Research Inc/RenderMonkey 1.6/Examples/Media/Models/Sphere.3ds";
float4x4 matView : ViewProjection;
float4x4 matProjection : ViewProjection;
float4x4 matWorld : World;
struct VS_INPUT
{
float4 Position : POSITION0;
float3 Normal : NORMAL0;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float3 normal : TEXCOORD0;
};
VS_OUTPUT Position_Pass_0_Vertex_Shader_vs_main( VS_INPUT Input )
{
VS_OUTPUT Output;
float4x4 matViewProjection=mul(matView,matProjection);
float4 pos = mul( matWorld, Input.Position );
Output.Position = mul( matViewProjection, pos );
float4 n=mul( matWorld, float4(Input.Normal, 1.0f) );
//float4 n2=mul(matViewProjection,n);
Output.normal=float3(n.x,n.y,n.z);
return( Output );
}
float4 Position_Pass_0_Pixel_Shader_ps_main(float3 n : TEXCOORD0) : COLOR0
{
float3 l=float3(0.0f, 1.0f, 0.0f);
return( float4(1.0f,0.0f,0.0f,1.0f)*dot(n,l));
}
//--------------------------------------------------------------//
// Technique Section for Position
//--------------------------------------------------------------//
technique Position
{
pass Pass_0
{
PixelShader = compile ps_2_0 Position_Pass_0_Pixel_Shader_ps_main();
}
}
float4 Position_Pass_0_Pixel_Shader_ps_main(float3 n : TEXCOORD0) : COLOR0
{
float3 l=float3(0.0f, 1.0f, 0.0f);
return( float4(1.0f,0.0f,0.0f,1.0f)*dot(n,l));
}
//--------------------------------------------------------------//
// Technique Section for Position
//--------------------------------------------------------------//
technique Position
{
pass Pass_0
{
PixelShader = compile ps_2_0 Position_Pass_0_Pixel_Shader_ps_main();
}
}
and my rendering loop looks like this:
void ngRenderer::render()
{
//DO CULLING
//RENDER BATCHES:
//Turn on the Z-Test
ngEngine &engine=ngEngine::getInstance();
engine.g_pD3DDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
int size=renderPools.size();
for(vector<ngRenderPool *>::iterator it=renderPools.begin();it!=renderPools.end();++it)
{
ngMaterial *mat=(**it).getMaterial();
unsigned int numPasses=mat->begin();
/*engine.g_pD3DDevice->SetTransform(D3DTS_WORLD,(**it).getWorldMatrix());
engine.g_pD3DDevice->SetTransform(D3DTS_VIEW,&engine.getViewMatrix());
engine.g_pD3DDevice->SetTransform(D3DTS_PROJECTION,&engine.getProjMatrix());*/
effect->SetMatrix("matWorld",(**it).getWorldMatrix());
effect->SetMatrix("matView",&engine.getViewMatrix());
effect->SetMatrix("matProjection",&engine.getProjMatrix());
for(unsigned int uiPass=0;uiPass < numPasses;uiPass++)
{
mat->beginPass(uiPass);
int meshCount;
CBaseMesh **mesh=(**it).getMeshPointer(&meshCount);
for(int i=0;i<meshCount;i++)
{
ngVertexBuffer *pVBuffer=(*mesh).pVBuff;
ngIndexBuffer *pIBuffer=(*mesh).pIBuff;
Draw(pVBuffer ,pIBuffer);
}
mat->endPass();
}
mat->end();
}
}
Where's the problem with this?
Edit: Ok i found the solution for that problem:
i forgot to compile the shader in the technique...
But now after adding the compilation i only get 1 black quad(of a cube) that deforms funny when i move the camera...
regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."