Book Image

Direct3D Rendering Cookbook

Book Image

Direct3D Rendering Cookbook

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Further Reading
Index

Tessellating bicubic Bezier surfaces


In this recipe, we will perform tessellation upon a bicubic Bezier control patch using the tessellation stages of the graphics pipeline. This tessellation will use the quad domain of the tessellator. We will update the CommonTess.hlsl shader code to include the methods to perform bicubic interpolation of the Bezier control points using De Casteljau's algorithm to subdivide a Bezier curve at an arbitrary point along the curve.

Getting ready

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

How to do it…

We will first implement the shader code for tessellating our Bezier control points. We will then implement a renderer for a bicubic Bezier surface. Consider the following steps:

  1. First within CommonTess.hlsl, we add the hull shader constant data structure to be generated for a Bezier patch:

    // Max 32 outputs
    struct HS_BezierPatchConstant {
        float EdgeTessFactor[4] : SV_TessFactor;
        float InsideTessFactor...