我正在尝试一些基于形态的顶点动画,但我得到了#342个错误告诉我:
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (NR_POSITION,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (NORMAL,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOUR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'UV' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (BLEND,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (LS_POSITION,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
这让我非常困惑,因为看我的着色器,顶点着色器的输出与像素着色器的输入完全匹配,这是我通过复制将输入从像素着色器粘贴到顶点着色器,而不是修复问题来确认的。我现在很困惑,因为我不知道是怎么回事。我在某个地方读到过,如果不设置输出值,它就会被丢弃,这会导致链接错误,但是我正在设置所有的值,但仍然得到了错误。
这是我的着色代码:
顶点着色器
struct MorphShaderInput
{
float4 position : POSITION;
uint index : INDEX; // Not at all a position but the input layout screams if I don't call it as such
};
struct MorphShaderOutput
{
float4 position : SV_POSITION;
float4 NR_Position : NR_POSITION;
float4 normal : NORMAL;
float3 colour : COLOUR;
float2 uv : UV;
float blend : BLEND;
float4 positionLightSpace : LS_POSITION;
};
struct morphPoint
{
float4 position;
float4 normal;
};
// A structured buffer of the previous frame's values
StructuredBuffer<morphPoint> firstPoint : register(t0);
// A structured buffer of the next frame's values
StructuredBuffer<morphPoint> secondPoint : register(t1);
cbuffer interpolationValue : register(b1) // (This buffer is in slot 1 and not 0)
{
matrix morphWvp;
matrix morphSpace;
float iValue;
}
MorphShaderOutput main(MorphShaderInput input)
{
MorphShaderOutput output;
float4 morphedPosition = (iValue * firstPoint[input.index].position) + ((1.0f - iValue) * secondPoint[input.index].position);
float4 morphedNormal = (iValue * firstPoint[input.index].normal) + ((1.0f - iValue) * secondPoint[input.index].normal);
output.position = mul(morphedPosition, morphWvp);
output.NR_Position = mul(morphedPosition, morphSpace);
output.normal = mul(morphedNormal, morphSpace);
output.colour = float3(0.7f, 0.7f, 0.7f);
output.uv = float2(0, 0);
output.blend = 1.0f;
output.positionLightSpace = float4(0.0f, 0.0f, 0.0f, -1.0f);
return output;
}
像素着色器
Texture2D rockTexture : register(t0);
Texture2D dirtTexture : register(t1);
Texture2D grassTexture : register(t2);
Texture2D shadowMap : register(t3);
SamplerState Sampler : register(s0);
SamplerState ShadowSampler : register(s1);
struct PixelShaderInput
{
float4 position : SV_POSITION;
float4 NR_Position : NR_POSITION;
float4 normal : NORMAL;
float3 colour : COLOUR;
float2 uv : UV;
float blend : BLEND;
float4 positionLightSpace : LS_POSITION;
};
cbuffer phongLighting : register(b0)
{
float4 l_pos;
float4 l_cam;
float l_amb;
float l_dif;
float l_spc;
}
cbuffer shadowMapping : register(b1)
{
matrix wvpLight;
matrix inverseWorld;
float2 mapSize;
}
float4 main(PixelShaderInput input) : SV_TARGET
{
// Does containt code that works when linked with other vertex shaders. I don't think the contents here matters to the linkage error
}
发布于 2021-05-22 16:18:13
好吧,难道我不觉得愚蠢吗?原来问题甚至不在着色器文件中,而是我制造了"VSGetShader()“类型而不是”VSSetShader()“类型。
对其他新手友好的提醒:记得检查你是否真的写了“设定”.
https://stackoverflow.com/questions/67651497
复制相似问题