顶点着色器 - 尽管匹配但像素着色器链接错误 Input/Output

Vertex Shader - Pixel Shader linkage error Despite Matching Input/Output

我正在尝试运行一些基于变形的顶点动画,但我收到 #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
}

好吧,我不觉得自己很蠢,事实证明问题甚至不在着色器文件中,而是我创建了“VSGetShader()”类型而不是“VSSetShader()”。

各位新手友情提示:记得核对一下你是不是真的写了“Set”...