[英]Color HLSL DirectX11
I'm new to directX11,i want to color my triangle so here is my VertexShader: 我是DirectX11的新手,我想为三角形着色,所以这是我的VertexShader:
PS_IN main( float4 pos : POSITION ,float4 color:COLOR)
{
PS_IN OUT;
OUT.color = color;
OUT.pos = pos;
return OUT;
}
and PS: 和PS:
float4 main(PS_IN OUT) : SV_TARGET
{
return OUT.color;
}
Not that PS_IN is a struct like this: 并非PS_IN是这样的结构:
struct PS_IN
{
float4 pos : SV_POSITION;
float4 color : COLOR;
};
what's wrong with it? 它出什么问题了? it shows absolutely nothing!
它绝对没有显示!
here is more detail: my input layout description and vertex struct: 这是更详细的信息:我的输入布局描述和顶点结构:
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 }
};
and here is vertices: 这是顶点:
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),
};
Triangle displayed perfectly just before i add color to it. 在我添加颜色之前,三角形显示完美。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.