I am doing some hardware tessellation and managed to get the basic subdivision effect, so tried to move on to Phong tessellation (which is for rounding edges). Now when I want to add extra outputs in the Patch Constant Function and write them, but one of those throws an error.
struct ConstantOutputType
{
float edges[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
float3 f3B0 : POSITION0;
float3 f3B1 : POSITION1;
float3 f3B2 : POSITION2;
float3 f3N0 : NORMAL0;
float3 f3N1 : NORMAL1;
float3 f3N2 : NORMAL2;
};
ConstantOutputType PatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)
{
ConstantOutputType output = (ConstantOutputType)0;
// Set the tessellation factors for the three edges of the triangle.
output.edges[0] = inputPatch[0].dep;
output.edges[1] = inputPatch[1].dep;
output.edges[2] = inputPatch[2].dep;
// Set the tessellation factor for tessallating inside the triangle.
output.inside = (inputPatch[0].dep + inputPatch[1].dep + inputPatch[2].dep)/3.0f;
output.f3B0 = inputPatch[0].pos.xyz;
output.f3B1 = inputPatch[1].pos.xyz;
output.f3B2 = inputPatch[2].pos.xyz;
//output.f3N0 = inputPatch[0].nor.xyz; <=====This throws the error (setting the normal)
output.f3N1 = inputPatch[1].nor.xyz;
output.f3N2 = inputPatch[2].nor.xyz;
return output;
}
The error thrown is: error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Components of input declaration for register 1 overlap with previous declaration for same register. Opcode #47 (count is 1-based). error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting. Which I can't seem to figure out what it means (given that it is my very first attempt at hull shader).
If I comment that out, it works, if I set an arbitary value for that, it also works (for example: output.f3N0 = float3(0,1,0) ). I also tried changing the semantics for the variables, but did not help. I would be very glad if someone could give me some insight on this.
UPDATE: Hull input follows, as requested:
struct HullInputType
{
float3 pos : POSITION;
float2 tex : TEXCOORD0;
float3 nor : TEXCOORD1;
float dep : TEXCOORD2;
};