Graphics Reference
In-Depth Information
void main( )
{
gl_out[ gl_InvocationID ].gl_Position =
gl_in[ 0 ].gl_Position; // (0,0,0,1)
tcRadius = vRadius[ 0 ];
tcCenter = vCenter[ 0 ];
gl_TessLevelOuter[0] = 2.;
//use scale and radius to help set the tessellation level
gl_TessLevelOuter[1] = uScale*tcRadius*uDetail;
gl_TessLevelOuter[2] = 2.;
gl_TessLevelOuter[3] = uScale*tcRadius*uDetail;
gl_TessLevelInner[0] = uScale*tcRadius*uDetail;
gl_TessLevelInner[1] = uScale*tcRadius*uDetail;
}
The TES, given by spheresubd.tes , turns the tessellation coordinates u and v
into angles, thus tessellating the sphere in spherical coordinates, and converts
those into rectangular coordinates that are scaled and translated to get the
actual triangle output coordinates. The normal is also computed as the radius
vector.
#version 400 compatibility
#extension GL_ARB_tessellation_shader : enable
uniform float uScale;
layout( quads, equal_spacing, ccw) in;
patch in vec3 tcCenter;
patch in float tcRadius;
out vec3 teNormal;
const float PI = 3.14159265;
void main( )
{
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
float w = gl_TessCoord.z;
//-pi/2 <= phi <= pi/2
// -pi <= theta <= pi
Search WWH ::




Custom Search