Jump to content
  • Advertisement
Sign in to follow this  
PhillipHamlyn

DX11 DirectX Tessellation Function for Triangles

This topic is 601 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi - I have the following simple patch function in DX11, but I keep getting rips, and when I look at the wireframe its clear that adjacent edges are not getting the same tessellation factor. The CalcTessFactor() function just does a distance from the camera to the point passed, so should always give the same value for the same edge center that I pass in.

 

PatchTess patchFunction_Far(InputPatch<VertexToPixel_Far, 3> patch, uint patchID : SV_PrimitiveID)
{
 PatchTess pt;
 // Compute midpoint on edges, and patch center
 float3 e0 = 0.5f*(patch[0].WorldPosition + patch[1].WorldPosition);
 float3 e1 = 0.5f*(patch[1].WorldPosition + patch[2].WorldPosition);
 float3 e2 = 0.5f*(patch[2].WorldPosition + patch[0].WorldPosition);
 float3  c = (patch[0].WorldPosition + patch[1].WorldPosition + patch[2].WorldPosition) / 3.0f;
 pt.EdgeTess[0] = CalcTessFactor(e0);
 pt.EdgeTess[1] = CalcTessFactor(e1);
 pt.EdgeTess[2] = CalcTessFactor(e2);
 pt.InsideTess = CalcTessFactor(c);
 
 return pt;
}

 

My patches are triangles.

 

Is there something I'm doing trivially wrong here (like assuming that EdgeTess[0] is correctly assumed to be edge 0-1, rather than edge 2->0 for instance ? - its a wild guess..

Share this post


Link to post
Share on other sites
Advertisement

Should be opposite:

 

 
struct PatchOutputType
{
float edges[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
 
 
PatchOutputType ExamplePatchFunction(InputPatch<HullInputVertice, 3> input)
{
PatchOutputType output;
 
output.edges[2] = FactorFromPoints(input[0].pos.xy, input[1].pos.xy);
output.edges[0] = FactorFromPoints(input[1].pos.xy, input[2].pos.xy);
output.edges[1] = FactorFromPoints(input[0].pos.xy, input[2].pos.xy);
output.inside = FactorFromPoints((input[0].pos.xy + input[1].pos.xy + input[2].pos.xy) / 3.0f);
 
return output;
}
 

Share this post


Link to post
Share on other sites

Thanks TeaTreaTim - that works fine now.

 

Out of interest, how did you know which of the edge indexes were correct ? I couldn't find any docs on this.

Edited by PhillipHamlyn

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!