Graphics Reference
In-Depth Information
Getting ready
For this recipe, we will be continuing on from the recipe, Tessellating a triangle and quad ,
and will be using the completed mesh renderer C# class from Chapter 4 , Animating Meshes
with Vertex Skinning .
The completed project for this recipe can be found in the Ch05_02TessellatedMesh
project within the companion source code.
How to do it…
We will first update the MeshRenderer class to supply a patch list with three control points.
Then, we will continue to implement a Phong tessellation domain shader. Consider the
following steps:
1.
Create a copy of the MeshRenderer class named TessellatedMeshRenderer ,
so that we don't get confused between the two classes later on.
2.
Find the location at which the primitive topology is set, and change it to the following:
// Set topology
context.InputAssembler.PrimitiveTopology =
SharpDX.Direct3D.PrimitiveTopology
.PatchListWith3ControlPoints;
This is all that we need to change in order to prepare the mesh renderer for the
tessellation pipeline.
3. We will use the triangle hull shaders from the previous project and use a modified
version of the domain shader to implement the Phong tessellation.
The Character.cmo model from Chapter 4 , Animating Meshes
with Vertex Skinning , requires the tessellation winding order to be
triangle_cw .
4. Create a new shader file called Shaders\TessellatePhong.hlsl , and remember
to change the encoding and build action.
5. Open the new shader file and add the following include directives:
#include "Common.hlsl"
#include "CommonTess.hlsl"
6.
Next, we will add a new function for orthogonally projecting a point on to a plane,
as follows:
// Orthogonal projection on to plane
// v2_projected = v2 - dot(v2-v1, n) * n;
 
Search WWH ::




Custom Search