I'm debugging my very simple shader and it's led me to a point where, as a quick test, I'm performing a multiplication of my position vector with an identity matrix. If I don't perform this multiplication, my position is preserved and I get a nice-looking quad in the middle of the screen, as expected. If I multiply with an identity matrix, my quad goes away, leaving only the background. I'm sure I'm missing something, or doing something stupid (or both), but I have no idea what that is. My code is below:

struct VOut
    float4 position : SV_POSITION;
    float4 color : COLOR;

struct VIn
    float4 position: POSITION0;
    float4 color: COLOR0;
    float2 texcoord: TEXCOORD0;
    float2 pad: PADDING0;
    matrix translate: CUSTOM0;

matrix Identity =
    { 1, 0, 0, 0 },
    { 0, 1, 0, 0 },
    { 0, 0, 1, 0 },
    { 0, 0, 0, 1 }

VOut VSMain(VIn input)
    VOut output;
    float4 pos = float4(input.position.x / 4, input.position.y / 4, 0.0, 1.0);
    matrix trans = Identity;
    pos = mul(pos, trans); // <-- THIS LINE HERE DOESN'T DO WHAT I EXPECT
    output.position = pos;
    output.color = input.color;
    return output;

The line marked above should produce identical output to the pos input, but it does not.

  • \$\begingroup\$ Ensure that you don't get any warnings from the debug runtime and verify that your shaders compiled properly. Ensure that all calls that return a HRESULT SUCCEEDED(). Use a graphics debugger like VSPix or RenderDoc to verify parameters and state. Your question is too open-ended to answer as it stands. \$\endgroup\$ Commented May 25, 2015 at 13:15

1 Answer 1


Turns out I needed to make the identity matrix static.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .