Sign in to follow this  
terryeverlast

trying to implement Bézier triangle patches

Recommended Posts

I need some advice on implementing bezier triangle patches.

First question.

Do I pump in only 3 vertices for the triangle or 10 vertices to my vertex shader. Or do I make the control points in the shader

ex...a triangle with 10 vertices

TriaBezierPatch.gif

 

And second...what are some extra ideas about implementing Triangle np ...Will I have to find the berstein and derivative of berstein and implement on a surface sum for normal and  for the Bezier curve??what would be the degree?

Edited by terryeverlast

Share this post


Link to post
Share on other sites

Yes, you can send all 10 control points through your vertex shader and into your hull shader. In the most basic implementation, your hull shader will set some tesselation factors and spit out the control points again. 

 

In your domain shader, you'll have access to all the points your hull shader output along with a SV_DomainLocation value that you can use to output an evaluated point on your surface. You can use this to perform whatever evaluation you want. 

 

 

Alternatively you could store your control points in a different data structure -- you're not strictly tied to keeping them in a vertex buffer. For instance, you might put them in a texture or buffer and sample them in your hull shader perhaps. But processing control points as vertex data is the most simple.

Edited by Dingleberry

Share this post


Link to post
Share on other sites

I can do a berzier curve on a rectangle by summing up all the points in the domain shader in this order...


float3 CubicBezierSum(const OutputPatch<HullOut, 16> bezpatch, float4 basisU, float4 basisV)
{
    float3 sum = float3(0.0f, 0.0f, 0.0f);
    sum  = basisV.x * (basisU.x*bezpatch[0].PosL  + basisU.y*bezpatch[1].PosL  + basisU.z*bezpatch[2].PosL  + basisU.w*bezpatch[3].PosL );
    sum += basisV.y * (basisU.x*bezpatch[4].PosL  + basisU.y*bezpatch[5].PosL  + basisU.z*bezpatch[6].PosL  + basisU.w*bezpatch[7].PosL );
    sum += basisV.z * (basisU.x*bezpatch[8].PosL  + basisU.y*bezpatch[9].PosL  + basisU.z*bezpatch[10].PosL + basisU.w*bezpatch[11].PosL);
    sum += basisV.w * (basisU.x*bezpatch[12].PosL + basisU.y*bezpatch[13].PosL + basisU.z*bezpatch[14].PosL + basisU.w*bezpatch[15].PosL);




    return sum;
}
Edited by terryeverlast

Share this post


Link to post
Share on other sites

If i submit 10 points into the vertex shader for a Triangle, how would i put the triangle together in the domain shader to make it a perfect triangle. What would be the order of control points. The post above is the order for a rectangle. I need a triangle order..

Edited by terryeverlast

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this