I have been struggle with this problem for a while and I can't figure it out.
I'm getting the below error a number of times:
D3D11 ERROR: ID3D10Device::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
//Vertex shader input
struct VS_NORMALMAP_INPUT
{
float3 Pos : POSITION;
float3 Normal : NORMAL;
float3 Tangent : TANGENT;
float2 UV : TEXCOORD0;
};
//Vertex shader output
struct VS_LIGHTING_OUTPUT
{
float4 ProjPos : SV_POSITION; // 2D "projected" position for vertex (required output for vertex shader)
float3 WorldPos : POSITION;
float3 WorldNormal : NORMAL;
float3 Tangent : TANGENT;
float2 UV : TEXCOORD;
};
//Vertex shader
VS_BASIC_OUTPUT VS_PlainTexture(VS_BASIC_INPUT vIn)
{
VS_BASIC_OUTPUT vOut;
float4 modelPos = float4(vIn.Pos, 1.0f);
float4 worldPos = mul(modelPos, WorldMatrix);
float4 viewPos = mul(worldPos, ViewMatrix);
vOut.ProjPos = mul(viewPos, ProjMatrix);
vOut.UV = vIn.UV;
return vOut;
}
//Pixel Shader
float4 ShadowMapTex(VS_LIGHTING_OUTPUT vOut) : SV_Target
{
float3 modelNormal = normalize(vOut.WorldNormal);
float3 modelTangent = normalize(vOut.Tangent);
float3 modelBiTangent = cross(modelNormal, modelTangent);
float3x3 invTangentMatrix = float3x3(modelTangent, modelBiTangent, modelNormal);
float3 CameraDir = normalize(CameraPos - vOut.WorldPos.xyz);
float3x3 invWorldMatrix = transpose(WorldMatrix);
float3 cameraModelDir = normalize(mul(CameraDir, invWorldMatrix));
float3x3 tangentMatrix = transpose(invTangentMatrix);
float2 textureOffsetDir = mul(cameraModelDir, tangentMatrix);
float texDepth = ParallaxDepth * (NormalMap.Sample(Trilinear, vOut.UV).a - 0.5f);
float2 offsetTexCoord = vOut.UV + texDepth * textureOffsetDir;
float3 textureNormal = 2.0f * NormalMap.Sample(Trilinear, offsetTexCoord) - 1.0f;
float3 worldNormal = normalize(mul(mul(textureNormal, invTangentMatrix), WorldMatrix));
float3 Light1Dir = normalize(LightPos1 - vOut.WorldPos.xyz);
float3 Light1Dist = length(LightPos1 - vOut.WorldPos.xyz);
float3 DiffuseLight1 = LightColour1 * max(dot(worldNormal.xyz, Light1Dir), 0) / Light1Dist;
float3 halfway = normalize(Light1Dir + CameraDir);
float3 SpecularLight1 = DiffuseLight1 * pow(max(dot(worldNormal.xyz, halfway), 0), SpecularPower);
float3 Light2Dir = normalize(LightPos2 - vOut.WorldPos.xyz);
float3 Light2Dist = length(LightPos2 - vOut.WorldPos.xyz);
float3 DiffuseLight2 = LightColour2 * max(dot(worldNormal.xyz, Light2Dir), 0) / Light2Dist;
halfway = normalize(Light2Dir + CameraDir);
float3 SpecularLight2 = DiffuseLight2 * pow(max(dot(worldNormal.xyz, halfway), 0), SpecularPower);
float4 SpotlightViewPos = mul(float4(vOut.WorldPos, 1.0f), SpotlightViewMatrix);
float4 SpotlightProjPos = mul(SpotlightViewPos, SpotlightProjMatrix);
float3 SpotlightDir = normalize(SpotlightPos - vOut.WorldPos.xyz);
if (dot(SpotlightFacing, -SpotlightDir) > SpotlightCosAngle) //**** This condition needs to be written as the first exercise to get spotlights working
{
float2 shadowUV = 0.5f * SpotlightProjPos.xy / SpotlightProjPos.w + float2(0.5f, 0.5f);
shadowUV.y = 1.0f - shadowUV.y;
float depthFromLight = SpotlightProjPos.z / SpotlightProjPos.w;// - DepthAdjust; //*** Adjustment so polygons don't shadow themselves
if (depthFromLight < ShadowMap1.Sample(PointClamp, shadowUV).r)
{
float3 SpotlightDist = length(SpotlightPos - vOut.WorldPos.xyz);
diffuseLight3 = SpotlightColour * max(dot(worldNormal.xyz, SpotlightDir), 0) / SpotlightDist;
float3 halfway = normalize(SpotlightDir + cameraDir);
specularLight3 = diffuseLight3 * pow(max(dot(worldNormal.xyz, halfway), 0), SpecularPower);
}
}
float3 DiffuseLight = AmbientColour + DiffuseLight1 + DiffuseLight2 + diffuseLight3;
float3 SpecularLight = SpecularLight1 + SpecularLight2 + specularLight3;
float4 DiffuseMaterial = DiffuseMap.Sample(Trilinear, offsetTexCoord);
float3 SpecularMaterial = DiffuseMaterial.a;
float4 combinedColour;
combinedColour.rgb = DiffuseMaterial * DiffuseLight + SpecularMaterial * SpecularLight;
combinedColour.a = 1.0f; // No alpha processing in this shader, so just set it to 1
return combinedColour;
}
Any advice to help diagnose this problem will be much appreciated.
I apologies if I provided to much information.