I begin to learning direct3d10 and stuck with multiple passes. As input I have a triangle(that stored in vb/ib) and effect file:
//some vertex shader and globals goes there. skip them to preserve simplicity
float4 ColorPixelShader(PixelInputType input) : SV_Target
{
return float4(1,0,0,0);
}
float4 ColorPixelShader1(PixelInputType input) : SV_Target
{
return float4(0,1,0,0);
}
technique10 ColorTechnique
{
pass pass0
{
SetVertexShader(CompileShader(vs_4_0, ColorVertexShader()));
SetPixelShader(CompileShader(ps_4_0, ColorPixelShader()));
SetGeometryShader(NULL);
}
pass pass1
{
SetVertexShader(CompileShader(vs_4_0, ColorVertexShader()));
SetPixelShader(CompileShader(ps_4_0, ColorPixelShader1()));
SetGeometryShader(NULL);
}
}
And some render code:
pass1->Apply(0);
device->DrawIndexed(indexCount, 0, 0);
pass2->Apply(0);
device->DrawIndexed(indexCount, 0, 0);
What I'd expect to see is the green triangle, but it always shows me red triangle. What am I doing wrong?
Also, I've got another question - should I set vertex shader in every pass?
I've added ColorVertexShader1 that translates vertex position by some delta, and 've got following picture: http://imgur.com/Oe7Qj