FXC is giving me this error when I try to compile my shader. I couldn't find anything on the internet related to this error. I have a tessellation shader that I want to add clipping to. MSDN says that SV_CLIPDISTANCE is writable from both the vertex shader and the geometry shader, so I tried to output from the vertex shader first and got this error:
Error 46 invalid hs_5_0 control point input semantic 'SV_CLIPDISTANCE0'
So I figured maybe you can't do it from there when using a hull shader. I added a geometry shader to the effect and now the error I get is this:
Error 46 No valid DomainShader-GeometryShader combination could be found in Technique Tessellation, Pass P0.
I'm guessing this might have something to do with the configuration of inputs/outputs being wrong, since I can't really find any tutorial on geometry shaders, let alone using one with tessellation. This is my shader:
#include <Shared.fx>
float3 Padding;
int TessellationFactor;
float TessellationNoise = 0.5f;
Texture2DArray DisplacementMap;
SamplerState displacementSampler
{
Filter = Anisotropic;
AddressU = Wrap;
AddressV = Wrap;
MaxAnisotropy = 16;
};
struct VertexInputType
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float3 TexCoord : TEXCOORD0;
float Shadow : COLOR0;
float Index : INDEX;
uint Damage : DAMAGE;
};
struct HullInputType
{
float4 Position : POSITION;
float3 TexCoord : TEXCOORD0;
float3 Normal : NORMAL;
float Shadow : COLOR0;
float Selected : INDEX;
uint Damage : DAMAGE;
};
struct ConstantOutputType
{
float edges[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
struct HullOutputType
{
float3 Position : POSITION;
float3 TexCoord : TEXCOORD0;
float3 Normal : NORMAL;
float Shadow : COLOR0;
float Selected : INDEX;
uint Damage : DAMAGE;
};
struct GSInput
{
float4 Position : SV_POSITION;
float3 Normal : NORMAL;
float3 TexCoord : TEXCOORD0;
float3x3 TangentToWorld : TEXCOORD1;
float Shadow : COLOR0;
float Clip : CLIPDISTANCE;
float Selected : INDEX;
uint Damage : DAMAGE;
};
struct PixelInputType
{
float4 Position : SV_POSITION;
float3 Normal : NORMAL;
float3 TexCoord : TEXCOORD0;
float3x3 TangentToWorld : TEXCOORD1;
float Shadow : COLOR0;
float Clip : SV_CLIPDISTANCE0;
float Selected : INDEX;
uint Damage : DAMAGE;
};
HullInputType VS(VertexInputType input)
{
HullInputType output;
output.Position = float4(input.Position, 1);
output.TexCoord = input.TexCoord;
output.Normal = input.Normal;
output.Shadow = input.Shadow;
output.Selected = input.Index;
output.Damage = input.Damage;
return output;
}
ConstantOutputType TessPatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)
{
ConstantOutputType output;
// Edge factor
output.edges[0] = TessellationFactor;
output.edges[1] = TessellationFactor;
output.edges[2] = TessellationFactor;
// Center factor
output.inside = TessellationFactor;
return output;
}
//--------------------------------------------------------------------------------------
// Hull Shader
//--------------------------------------------------------------------------------------
[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("TessPatchConstantFunction")]
HullOutputType HS(InputPatch<HullInputType, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
{
HullOutputType output;
output.Position = patch[pointId].Position;
output.TexCoord = patch[pointId].TexCoord;
output.Normal = patch[pointId].Normal;
output.Shadow = patch[pointId].Shadow;
output.Selected = patch[pointId].Selected;
output.Damage = patch[pointId].Damage;
return output;
}
//--------------------------------------------------------------------------------------
// Domain Shader
//--------------------------------------------------------------------------------------
[domain("tri")]
PixelInputType DS(ConstantOutputType input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<HullOutputType, 3> patch)
{
GSInput output;
...
return output;
}
//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
[maxvertexcount(3)]
void GS( triangle GSInput input[3], inout TriangleStream<PixelInputType> triStream )
{
PixelInputType output;
for( uint i=0; i < 3; i += 1 )
{
output.Position = input.Position;
output.Normal = input.Normal;
output.TexCoord = input.TexCoord;
output.TangentToWorld = input.TangentToWorld;
output.Shadow = input.Shadow;
output.Selected = input.Selected;
output.Damage = input.Damage;
output.Clip = input.Clip;
triStream.Append( output );
}
triStream.RestartStrip();
}
PixelShaderOutput PS(PixelInputType input)
{
PixelShaderOutput output;
...
return output;
}
technique11 Tessellation
{
pass P0
{
SetGeometryShader(CompileShader(gs_5_0, GS() ));
SetHullShader( CompileShader( hs_5_0, HS() ) );
SetDomainShader( CompileShader( ds_5_0, DS() ) );
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetPixelShader( CompileShader( ps_5_0, PS() ) );
}
}