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 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.
This repo demonstrates how to use OpenGL's tessellation shaders to render Bézier curves and surfaces. These curves and surfaces are an intuitive, extendable, and numerically stable way to add natural curves and 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!
Looking at the structure of the tessellation shader I believe it was built for these types of operations. As such the purpose of the files in each demonstration 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 around. |
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 rectangle around. |
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. |
And more to come!
- Set-up: For general SDL examples and set-up advice consider Lazy Foo' Productions SDL Tutorials.
- Tessellation Shader: For background on the Tessellation Shader consult the OpenGL wiki's Tessellation page.
- Mathematics: For further reading into how the presented algorithms work consider reading "Curves and Surfaces for CAGD: A Practical Guide".