我是directX11的新手,我想为三角形着色,所以这是我的VertexShader:
PS_IN main( float4 pos : POSITION ,float4 color:COLOR)
{
PS_IN OUT;
OUT.color = color;
OUT.pos = pos;
return OUT;
}
和PS:
float4 main(PS_IN OUT) : SV_TARGET
{
return OUT.color;
}
不是说PS_IN是这样的结构:
struct PS_IN
{
float4 pos : SV_POSITION;
float4 color : COLOR;
};
它有什么问题?它绝对没有显示!
答案 0 :(得分:-1)
这里有更多细节: 我的输入布局描述和顶点结构:
struct Vertex
{
Vertex();
XMFLOAT3 pos;
XMFLOAT4 color;
Vertex(float x, float y, float z,float cr,float cg,float cb,float ca) : pos(x, y, z),color(cr,cg,cb,ca){}
};
D3D11_INPUT_ELEMENT_DESC IED[]=
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
这里是顶点:
Vertex vertices[] =
{
Vertex(0.0f, 0.5f, 0.5f,1.0f,1.0f,0.0f,1.0f),
Vertex(0.5f, -0.5f, 0.5f,0.0f,0.0f,1.0f,1.0f),
Vertex(-0.5f, -0.5f, 0.5f,0.0f,1.0f,1.0f,0.0f),
};
在我添加颜色之前,三角形显示完美。