Home Game Development shaders – Object caught to display screen it doesn’t matter what eye place is used

shaders – Object caught to display screen it doesn’t matter what eye place is used

0
shaders – Object caught to display screen it doesn’t matter what eye place is used

[ad_1]

I’ve run into a difficulty when attempting to put in writing a easy rendering program in D3D11. I’m 90% positive it is to do with some defective matrix multiplication or technology, however I’ve tried debugging the values of the matrices they usually appear nice to me.

The downside is that irrespective of the place I transfer the attention place, the rendered dice at all times seems the identical.

The ensuing display screen picture is like this:

Colourful gradients

Each vertex of the dice has a unique color, and the pixel shader must be mixing between them, so the gradient impact you’ll be able to see is between 4 vertices of the dice.

Here’s a few of my code

eyePos = XMVectorSet(0.0f, 1.0f, -5.0f, 0.0f);
lookAtPos = XMVectorSet(0.0f,1.0f,0.0f,0.0f);
up = XMVectorSet(0.0f,1.0f,0.0f,0.0f);

world = XMMatrixIdentity();
view = XMMatrixLookAtLH(eyePos, lookAtPos, up);
projection = XMMatrixPerspectiveFovLH(XM_PIDIV2, 1000.0f / 680.0f, 0.01f, 100.0f);

_pIContext->IASetVertexBuffers(0, 1, &_vertexBuffer, &stride, &offset);
_pIContext->IASetIndexBuffer(_indexBuffer, DXGI_FORMAT_R16_UINT, 0);
_pIContext->VSSetConstantBuffers(0, 1, &_cbWorldBuffer);
_pIContext->VSSetConstantBuffers(1, 1, &_cbViewBuffer);
_pIContext->VSSetConstantBuffers(2, 1, &_cbProjBuffer);

And then for shader code, we have…

cbuffer worldBuffer : register(b0) {
    matrix World;
    float t;
}

cbuffer viewBuffer : register(b1) {
    matrix View;
}

cbuffer projectionBuffer : register(b2) {
    matrix Projection;
}

PS_INPUT vs(float4 pos : POSITION, float4 col : COLOUR) {
    PS_INPUT output = (PS_INPUT)0;
    output.Pos = mul(pos, World);
    output.Pos = mul(pos, View);
    output.Pos = mul(pos, Projection);

    output.Colour = col;
    return output;
}

float4 ps(PS_INPUT enter) : SV_TARGET{
    return enter.Colour;
}

My intestine tells me it is the projection matrix, though I’ve based mostly this on one other undertaking I did, and evaluating the code, I am unable to discover out what I’ve finished in another way.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here