Book Image

Direct3D Rendering Cookbook

By : Justin Stenning, Justin Stenning
Book Image

Direct3D Rendering Cookbook

By: Justin Stenning, Justin Stenning

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
About the Author
About the Reviewers
Further Reading

Tessellating a triangle and quad

In this recipe, we will perform tessellation upon a triangle and a quad patch. We will create the hull and domain shaders that are necessary to use the triangle and quad tessellation domains, respectively.

As the fixed function tessellation stage is used to define new vertices, it is necessary to move some of the vertex shader code into the applicable domain shader, such as applying the ViewProjection matrix and calculating the interpolated vertex normal and texture coordinates.

We will update the CommonTess.hlsl shader code to perform barycentric interpolation, to calculate the attributes for new vertices in a triangle domain, and bilinear interpolation to interpolate between the four attributes within the quad domain.

Getting ready

We will continue from the previous recipe, Preparing the vertex shader and buffers for tessellation.

For this recipe, we will also re-use the triangle and quad renderers from the recipe Rendering primitives in Chapter 2, Rendering...