Sunday, November 6, 2022
HomeGame Developmentshaders - Object caught to display it doesn't matter what eye place...

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


I’ve run into a difficulty when making an attempt to jot down a easy rendering program in D3D11. I am 90% positive it is to do with some defective matrix multiplication or era, however I’ve tried debugging the values of the matrices they usually appear nice to me.

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

The ensuing display picture is like this:

Colourful gradients

Every 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 is 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);

After which 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.Color = col;
    return output;
}

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

My intestine tells me it is the projection matrix, though I’ve primarily based this on one other venture I did, and evaluating the code, I can not discover out what I’ve carried out in another way.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments