Graphics Reference
In-Depth Information
float phi = PI * ( u - .5 ); // spherical coordinates
float theta = 2. * PI * ( v - .5 );
float cosphi = cos(phi);
vec3 xyz = vec3( cosphi*cos(theta), sin(phi),
cosphi*sin(theta) );
teNormal = xyz;
xyz *= ( uScale * tcRadius );
xyz += tcCenter;
gl_Position = uModelViewMatrix * vec4( xyz,1. );
// the shrink GS will multiply by the Projection matrix
}
The output of these shaders is shown in Figure 13.19, where the same three
spheres have different levels of detail and different scale. As in the sphere
octant example, notice that the first image has larger triangles, while the sec-
ond and third images have roughly the same level of detail since the radius is
used in defining the tessellation levels.
Figure 13.19. Three spheres as above with different values of detail and scale: uDetail = 30., uScale = 1. (left);
uDetail = 50., uScale = 1. (center); uDetail = 50., uScale = 2.5 (right).
Whole Sphere Subdivision while Adapting to Screen Coverage
This is good as far as it goes, but having to use uScale is restrictive. We would
much rather use our usual user interface (whatever that is) to arbitrarily scale,
rotate, and translate, and have the shader figure out what the right tessellation
Search WWH ::




Custom Search