Skip to content

CleisthenesH/Tessellating-Bezier-Curves-and-Surface

Repository files navigation

⚠️Living Document: All Parts are Subject to Change⚠️

Tessellating Bézier Curves and Surface

This repo demonstrates how to use OpenGL's tessellation shaders to render Bézier curves and surfaces. Such curves and surfaces are an intuitive, extendable, and numerically stable way to add character to renders. And the tessellation shaders provide a performance minded and memory efficient way to implement Bézier curves and surfaces in OpenGL, what a great combination!

A picture of a Bicubic Bézier surface
A Bicubic Bézier surface whoes trianglulation was calculated in the Tesselation shader. Only the 16 white points where sent to the graphics card.

A picture of a Conic section
A Conic section defined by three points and two tangents caulated as a rational quadratic Bézier curve. Only 3 points where sent to the graphics card.

A picture composite cubic Bézier curve
A composite cubic Bézier with velocity continuity. The geometry is specified once and locally at each point defining the curve.

A picture of the intersections of a cubic Bézier curve with the x-axis.
The intersections of a cubic Bézier curve with the x-axis. The intersections are calculated CPU side and the curve is rendered using the normal method.

Summaries

Looking at the structure of the tessellation shader I believe it was built for these types of operations. As such the purpose of each file in the demonstrations follows naturally from their shader type, which can be read about here, with main.c acting as minimal driving code to build the shanders and send them user input. Hence the following table only gives a mathematical summary of each demonstration:

Demonstration Summary
cubic curve Implementation of a cubic Bézier curve which can be thought of as a smooth line between two end point and their tangents.
bicubic rectangle Implementation of a bicubic Bézier surface which can be thought of as a soft rectangle controlled by 16 points which can be used to 'pull' the rectangle towards them.
cubic triangle Implementation of a biquadratic Bézier surface which can be thought of as a soft triangle controlled by 10 points which can be used to 'pull' the triangle towards them.
conic section Implementation of a rational quadratic Bézier curve which can be thought of as as the conic section between two endpoints, their tangents, and an arbitrary third point.
width and color Implementation of a cubic Bézier curve where both width and color are also parameterized by the control points alongside position.
composite curve Implementation of a composite Bézier curve with velocity continuity such that the geometry is specified once and locally at each point defining the curve.
intersections Implementation of the intersections of a cubic Bézier curve and a line using iterative subdivision. Note that the intersection isn't directly related to OpenGl and reuses the shaders from the cubic curve demonstration.

And more to come!

Additional resources

About

Using OpenGL's tessellation shaders to render Bézier curves and surfaces.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published