We will create a struct for the tessellation factors so the tessellation program can get them as a single package.Īs we can see, the function takes in a patch. As these numbers vary, so do the patterns and complexity. Because we're dealing with triangles we need to define 4 separate factors: one for each edge, and one for the inside. As this function will be returning the tessellation factors, let's talk about those. As you'll note, that's also what we named it. So, now we need to implement our other half of the hull program this is referred to as the patch constant function. Lastly, because we are only returning one control point at a time, we need to specify which one in the patch we are working with, so we also take in an ID as well as a patch. In our case, we want the full 1 to 64 range, so we'll partition them as integers. The partitioning refers to how the tessellation factors will be interpreted. In our case, because we want the faces to face us, they will wind clockwise. output topology refers to the winding of the triangles. There are two attributes I did not mention. And, for the purpose of this tutorial, we'll keep them as simple as possible. To do this, we'll define two separate vertex programs. However, because we end up with more vertices than we started with, the vertex program will need to be called twice. The tessellation pipeline is actually sandwiched between these two programs, so they mostly stay the same. Let's start with the vertex and fragment programs. While we're at it, change the name of the vertex and fragment programs to "VertexProgram" and "FragmentProgram" and update their pragma's accordingly. So begin by removing all fog related code, and adding in "#pragma target 4.6" with the other "#pragma"'s. We're going to leave most of the things the same. We'll start from a standard unlit shader. To do this, it takes in the control points from the hull program, its tessellation factors, and, last but not least, the tessellation points. The purpose of the domain program is to take the subdivided points the tessellation program has produced, and turn them into vertices that can be rendered. This stage takes in the control points and tessellation factors produced by the hull program and slices up the patch according to the defined domain (triangle, quad, isoline). ![]() ![]() Thankfully, what would be the most challenging part of tessellation is handled for us internally. To return the two outputs, the hull program is actually made up of two separate functions that operate in parallel. For the output, it returns the control points as well as calculated tessellation factors. Control points are essentially the original vertices that define the shape. Its input are the control points that make up a patch. Invoked once per patch (polygon), the hull stage takes one input and produces two output. The tessellation pipeline is separated into three stages: hull, tessellation, and domain. How does the Tessellation Pipeline function? For this tutorial, we'll be working with triangles. The reason I say shapes, is because DX11 allows for three distinct shapes: triangles, quads, or isolines. This can be used to enhance detail through increased geometry, or to make distortions and modifications to the mesh look more appealing or believable. Tessellation in relation to graphics, is the process of subdividing shapes into smaller versions of that shape. So, without further ado, let's get into it! By far the trickiest part of getting what I have so far was the dynamic tessellation, and with so few tessellation tutorials out there, I figured I'd try and give back to the community by sharing how to dynamically tessellate an object. ![]() Hello! I've been hard at work on my snow deformation shader, and this forum has been a huge help to me in getting it working.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |