Graphics Reference
In-Depth Information
Sphere Octants
As a first example, let's consider a single octant of a sphere. This has a tri-
angle at its base with vertices on each coordinate axis. If we take this as our
base geometry and interpolate it with a triangle patern, we can see some of
the essential features of a triangle tessellation. The .glib file for this example,
octantsubd.glib , is straightforward, with uniform slider variables for the tes-
sellation levels for you to experiment with. The geometry here is simply the
three-vertex patch in the first octant.
##OpenGL GLIB
Vertex octantsubd.vert
TessControl octantsubd.tcs
TessEvaluation octantsubd.tes
Geometry octantsubd.geom
Fragment octantsubd.frag
Program OctantSubd \
uRadius <0. 1. 3.> \
uOuter0 <1. 25. 50.> \
uOuter1 <1. 25. 50.> \
uOuter2 <1. 25. 50.> \
uInner <1. 10. 50.> \
uShrink <0. 1. 1.>
Color 1. 1. 0.
NumPatchVertices 3
glBegin gl_patches
glVertex 1. 0. 0.
glVertex 0. 1. 0.
glVertex 0. 0. 1.
glEnd
The vertex shader applies the modelview matrix to the vertex geometry.
The corresponding TCS file, octantsubd.tcs , copies the gl_Position values
from the gl_in[ ] array to the gl_out[ ] array for each vertex of the primitive
and calculates the tessellation levels from the .glib values.
#version 400 compatibility
#extension GL_ARB_tessellation_shader : enable
uniform float uOuter0, uOuter1, uOuter2, uInner;
uniform float uRadius;
Search WWH ::




Custom Search