저는 입력으로 정점의 위치, 일부 변환 행렬 및 정점의 색상에 대한 float4가있는 쉐이더를 생성하려고합니다. 위치의 조작 괜찮 작동하지만 그것을 밖으로 올바른 색상을 가져 오지.HLSL 쉐이더는 깔끔한 색상을 보여줍니다.
D3D11_INPUT_ELEMENT_DESC solidColorLayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
그리고 자신이 생겼 쉐이더 : 그래서 여기에 좋아
는 쉐이더의 Inputlayout입니다
망가 매트릭스 그 변화에 대해 confuesed받을cbuffer cbChangesEveryFrame : register(b0)
{
matrix worldMatrix;
};
cbuffer cbNeverChanges : register(b1)
{
matrix viewMatrix;
};
cbuffer cbChangeOnResize : register(b2)
{
matrix projMatrix;
};
struct VS_Input
{
float4 pos : POSITION;
float4 color : COLOR;
};
struct PS_Input
{
float4 pos: SV_POSITION;
float4 color: COLOR;
};
PS_Input VS_Main(VS_Input vert)
{
PS_Input vsout = (PS_Input)0;
vsout.color = vert.color;
float4 worldPos = mul(vert.pos, worldMatrix);
vsout.pos = mul(worldPos, viewMatrix);
vsout.pos = mul(vsout.pos, projMatrix);
return vsout;
}
float4 PS_Main(PS_Input psinput) : SV_TARGET
{
return psinput.color;
}
내가 올바른 vertexposition을 얻는 등 올바른지 만, 내가 정의한 색상을 얻지는 않는다.
그래서 예를 들어 나는이 같은 꼭지점 만들 :
struct VertexPos
{
XMFLOAT3 pos;
XMFLOAT4 color;
};
...
VertexPos vertices[] =
{
{ XMFLOAT3(-1.0f, 0.0f, -1.0f), XMFLOAT4(0.1f,0.1f, 0.1f, 0.1f)},
{ XMFLOAT3(1.0f, 0.0f, -1.0f), XMFLOAT4(0.1f, 0.1f, 0.1f, 0.1f) },
{ XMFLOAT3(1.0f, 0.0f, 1.0f), XMFLOAT4(0.1f, 0.1f, 0.1f, 0.1f) },
{ XMFLOAT3(-1.0f, 0.0f, 1.0f), XMFLOAT4(0.1f, 0.1f, 0.1f, 0.1f) },
};
일부 indexbuffer와를하고 drawcall 자체가 preaty 간단하다
unsigned int stride = sizeof(VertexPos);
unsigned int offset = 0;
//set inputlayout and topology for drawing the sprites
context->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);
context->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R16_UINT, 0);
//calculate cube stuff
XMMATRIX worldMat = getWorldMatrix();
worldMat = XMMatrixTranspose(worldMat);
context->UpdateSubresource(worldBuffer, 0, 0, &worldMat, 0, 0);//update world matrix
//draw
context->DrawIndexed(6, 0, 0);
그래서 내가 무슨 잘못 그것으로 궁금해? (라인과 작은 얼굴이 사이트에서 색상을 가져야 함)