Graphics Reference
In-Depth Information
// set the tessellation levels from that information using
// uDetail to make the conversion from NDC to screen space:
gl_TessLevelOuter[0] = 2.;
gl_TessLevelOuter[1] = dmax * uDetail;
gl_TessLevelOuter[2] = 2.;
gl_TessLevelOuter[3] = dmax * uDetail;
gl_TessLevelInner[0] = dmax * uDetail;
gl_TessLevelInner[1] = dmax * uDetail;
}
The big trick here is that the TCS is performing projection matrix mul-
tiply and homogeneous division itself. This is so that it can gain a sense of
how large a region these points will subtend in normalized device coordinates
(NDC), and thus how large the spheres will be when rendered on the screen.
The outer and inner tessellations are then derived from that information. Here
uDetail acts as a scale factor, and would normally be set by the application
to reflect the size of the display window in pixels as well as some measure of
your idea of what “pleasingly smooth” is.
The TES looks like this, which is the same as before except that there is
no uScale :
#version 400 compatibility
#extension GL_ARB_tessellation_shader : enable
layout( quads, equal_spacing, ccw) in;
patch in float tcRadius;
patch in vec3 tcCenter;
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;
float phi = PI * ( u - .5 );
float theta = 2. * PI * ( v - .5 );
float cosphi = cos(phi);
vec3 xyz = vec3( cosphi*cos(theta), sin(phi),
cosphi*sin(theta) );
Search WWH ::




Custom Search