Multiple passes in direct3d10

Posted by innochenti on Game Development See other posts from Game Development or by innochenti
Published on 2012-03-17T18:20:03Z Indexed on 2012/03/18 18:25 UTC
Read the original article Hit count: 151

Filed under:
|
|

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

© Game Development or respective owner

Related posts about c++

Related posts about rendering