I am using instancing in directx/hlsl to render two meshes from two views onto two different render targets. I have two view projection matrices which I am indexing using the InstanceId in the vertex shader. I see the VS Out in RenderDoc and it seems like the meshes are transformed correctly from the vertex shader. I am using the InstanceId in fragment shader to write some data to the corresponding render target in the following manner.

void MainPS(FTriangleIDPassGSToPS Input,
        out uint OutColor1 : SV_Target0,
        uint InstanceId : SV_InstanceID,
        out uint OutColor2 : SV_Target1)
{
    if(InstanceId)
    {
        OutColor2 = 10;
    }
    else
    {
        OutColor1 = 100;
    }
}

But when I visualize the two render targets in RenderDoc, I find that all the meshes have the same transformation. Although the values are different (RT 1 has values of 100 and RT 2 has values of 100), but I was expecting the meshes would be transformed according to the MVP used for that instance. In my case, both the meshes appear to have been viewed from the same viewpoint. Am I missing something ? I'm new to shader programming, so I might be doing something wrong. Thanks.

0 Answers