Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Directx 顶点着色器-像素着色器链接错误,尽管输入/输出匹配_Directx_Directx 11_Hlsl - Fatal编程技术网

Directx 顶点着色器-像素着色器链接错误,尽管输入/输出匹配

Directx 顶点着色器-像素着色器链接错误,尽管输入/输出匹配,directx,directx-11,hlsl,Directx,Directx 11,Hlsl,我正在尝试使用一些基于变形的顶点动画,但我得到了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 provid

我正在尝试使用一些基于变形的顶点动画,但我得到了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”…

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


对所有其他新手的友好提醒:记得检查您是否真的编写了“Set”…

复制那些
struct
s容易出错。考虑将它们放入一个常见的<代码> .HLSLI文件中,并将其包含在两个着色器中。复制那些<代码>结构> <代码> s是容易出错的。考虑将它们放入一个常见的<代码> .HLSLI文件中,并将其包含在两个着色器中。