Question

I've been writing a program using directx11, and I have written a basic camera class which manipulates a view matrix. When I test the program, the result is that the scene does not move, but when I move the camera it has the effect of cutting off what is visible at an arbitrary location. I've attached some pictures to show what I mean.

I have left my pixel shader only outputting red pixels for now.

My vertex shader is based on the SDK example:

cbuffer cbChangeOnResize : register(b1) { matrix Projection; };

cbuffer cbChangesEveryFrame : register(b2)
{
    matrix View;
    matrix World;
};


struct VS_INPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD0;
};

struct PS_INPUT
{
    float4 Pos : SV_POSITION;
    float2 Tex : TEXCOORD0;
};

PS_INPUT TEX_VS(VS_INPUT input)
{
    PS_INPUT output = (PS_INPUT)0;
    output.Pos = mul(input.Pos, World);
    output.Pos = mul(output.Pos, View);
    output.Pos = mul(output.Pos, Projection);
    output.Tex = input.Tex;

    return output;
}

I have been scratching my head for a couple of days about this problem, but I don't know what is causing this, or even which pieces of code are relevant. PIX shows that the world, view and projection matrices appear to exist and are being applied, although it is evident that something is not right.

Thank you.

Était-ce utile?

La solution

You can use row_major modifier instead of transposing matrices before passing them inside shader

Autres conseils

Mathematical fail, I had sent the view matrix instead of its transpose to the shader.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top