我将顶点发送到像素着色器阶段,图像在顶点和像素着色器之间的某处完全丢失。我花了几天时间试图解决这个问题,并且不知道发生了什么。这是我的顶点和像素着色器的代码。
//Pixel shader
cbuffer ConstantBuffer: register(b0) {
matrix World;
matrix View;
matrix Projection;
float4 vLightDir;
float4 vLightColor;
}
struct VS_INPUT {
float3 pos: POSITION;
float2 texcoord: TEXCOORD;
float3 norm : NORMAL;
};
struct PS_INPUT {
float4 Pos : SV_POSITION;
float3 norm: TEXCOORD0;
float2 texcoord : TEXCOORD1;
};
float4 PS(PS_INPUT pos) : SV_TARGET {
return float4(1,1,0,1);
//float4 finalcolor = 0;
// finalcolor+=saturate(dot(vLightDir,pos.norm)*vLightColor);
//return finalcolor;
}
//VERTEX SHADER
PS_INPUT VS( VS_INPUT pos )
{
PS_INPUT output;
output.Pos = mul(pos.pos,World);
output.Pos = mul(output.Pos,View);
output.Pos = mul(output.Pos,Projection);
output.norm = mul(pos.norm,World);
output.texcoord = pos.texcoord;
return output;
}