i'm trying to a mesh tessellate with dx11 with the tessellation factor calculated by the size of the triangle and the distance to the screen.
I do the same operation on the 3 edges of the triangle, so i would expect i get the same level of tesselation on the other triangle that shares the edge, but it seems like it doesn't. Does anyone have an idea why this doesn't work like expected?
I need the same amount of tessellation on the other side of the edge to do displacement mapping without any cracks.
There are 5 triangles in this image, the red "circle" is around 2 edges shared by 4 of the triangles in pairs.
float calcLod(float3 a, float3 b)
{
float dist = distance(a,b) ;
float3 center = (b+a)/2;
float camDist = distance(CameraPosition, center);
return dist * tesselationStrength / camDist;
}
hullShaderConstantOutput hullShaderConstant( InputPatch<vertexShaderOutput, 3> ip, uint pid : SV_PrimitiveID )
{
hullShaderConstantOutput output;
// get worldspace positions
float3 v0 = ip[0].position;
float3 v1 = ip[1].position;
float3 v2 = ip[2].position;
output.edges[0] = calcLod(v0, v1);
output.edges[1] = calcLod(v1, v2);
output.edges[2] = calcLod(v2, v0);
output.inside = (output.edges[0] + output.edges[1] + output.edges[2])/3;
return output;
}
[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("hullShaderConstant")]
hullShaderOutput hullShader( InputPatch<vertexShaderOutput, 3> input, uint pointId : SV_OutputControlPointID, uint pid : SV_PrimitiveID )
{
hullShaderOutput output;
output.position = input[pointId].position;
output.uv = input[pointId].uv;
output.tangentToWorld = input[pointId].tangentToWorld;
return output;
}